Package com.telenordigital.nbiot
Class ImmutableDevice
- java.lang.Object
-
- com.telenordigital.nbiot.ImmutableDevice
-
- All Implemented Interfaces:
Device
@ParametersAreNonnullByDefault @Immutable public final class ImmutableDevice extends Object implements Device
Immutable implementation ofDevice.Use the builder to create immutable instances:
new ImmutableDevice.Builder().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableDevice.BuilderBuilds instances of typeImmutableDevice.-
Nested classes/interfaces inherited from interface com.telenordigital.nbiot.Device
Device.DeviceList
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringcollectionID()The collection the device belongs to.static ImmutableDevicecopyOf(Device instance)Creates an immutable copy of aDevicevalue.booleanequals(Object another)This instance is equal to all instances ofImmutableDevicethat have equal attribute values.inthashCode()Computes a hash code from attributes:id,collectionID,imei,imsi,tags.Stringid()The device's EUI.Stringimei()The device's IMEI.Stringimsi()The device's IMSI.Map<String,String>tags()StringtoString()Prints the immutable valueDevicewith attribute values.ImmutableDevicewithCollectionID(String value)Copy the current immutable object by setting a value for thecollectionIDattribute.ImmutableDevicewithId(String value)Copy the current immutable object by setting a value for theidattribute.ImmutableDevicewithImei(String value)Copy the current immutable object by setting a value for theimeiattribute.ImmutableDevicewithImsi(String value)Copy the current immutable object by setting a value for theimsiattribute.ImmutableDevicewithTags(Map<String,? extends String> entries)Copy the current immutable object by replacing thetagsmap with the specified map.
-
-
-
Method Detail
-
collectionID
@Nullable public String collectionID()
The collection the device belongs to.- Specified by:
collectionIDin interfaceDevice
-
withId
public final ImmutableDevice withId(@Nullable String value)
Copy the current immutable object by setting a value for theidattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for id (can benull)- Returns:
- A modified copy of the
thisobject
-
withCollectionID
public final ImmutableDevice withCollectionID(@Nullable String value)
Copy the current immutable object by setting a value for thecollectionIDattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for collectionID (can benull)- Returns:
- A modified copy of the
thisobject
-
withImei
public final ImmutableDevice withImei(@Nullable String value)
Copy the current immutable object by setting a value for theimeiattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for imei (can benull)- Returns:
- A modified copy of the
thisobject
-
withImsi
public final ImmutableDevice withImsi(@Nullable String value)
Copy the current immutable object by setting a value for theimsiattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for imsi (can benull)- Returns:
- A modified copy of the
thisobject
-
withTags
public final ImmutableDevice withTags(@Nullable Map<String,? extends String> entries)
Copy the current immutable object by replacing thetagsmap with the specified map. Nulls are not permitted as keys or values. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
entries- The entries to be added to the tags map- Returns:
- A modified copy of
thisobject
-
equals
public boolean equals(@Nullable Object another)
This instance is equal to all instances ofImmutableDevicethat have equal attribute values.
-
hashCode
public int hashCode()
Computes a hash code from attributes:id,collectionID,imei,imsi,tags.
-
toString
public String toString()
Prints the immutable valueDevicewith attribute values.
-
copyOf
public static ImmutableDevice copyOf(Device instance)
Creates an immutable copy of aDevicevalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Parameters:
instance- The instance to copy- Returns:
- A copied immutable Device instance
-
-