yeg
6 天以前 a04222c873e5e55f48c8d33b5c0bc46fa524ac8d
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
package com.battery.device.api.model;
 
import java.util.Objects;
 
/** 设备身份;通道身份在此基础上增加通道号。 */
public record DeviceIdentity(String adapterCode, int devtype, int devid, int subdevid)
{
    public DeviceIdentity
    {
        adapterCode = Objects.requireNonNull(adapterCode, "adapterCode").trim();
        if (adapterCode.isEmpty()) throw new IllegalArgumentException("adapterCode must not be blank");
        if (devtype < 0 || devid < 0 || subdevid < 0)
            throw new IllegalArgumentException("device identity values must be non-negative");
    }
 
    /** 取通道身份中的设备部分,丢弃通道号。 */
    public static DeviceIdentity from(ChannelIdentity channel)
    {
        Objects.requireNonNull(channel, "channel");
        return new DeviceIdentity(channel.adapterCode(), channel.devtype(), channel.devid(), channel.subdevid());
    }
}