Package com.telenordigital.nbiot
Class ImmutableOutputDataMessage
- java.lang.Object
-
- com.telenordigital.nbiot.ImmutableOutputDataMessage
-
- All Implemented Interfaces:
OutputDataMessage
@ParametersAreNonnullByDefault @Immutable public final class ImmutableOutputDataMessage extends Object implements OutputDataMessage
Immutable implementation ofOutputDataMessage.Use the builder to create immutable instances:
new ImmutableOutputDataMessage.Builder().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableOutputDataMessage.BuilderBuilds instances of typeImmutableOutputDataMessage.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImmutableOutputDataMessagecopyOf(OutputDataMessage instance)Creates an immutable copy of aOutputDataMessagevalue.Devicedevice()The sending device.booleanequals(Object another)This instance is equal to all instances ofImmutableOutputDataMessagethat have equal attribute values.inthashCode()Computes a hash code from attributes:keepAlive,device,payload,received.booleankeepAlive()Ignore this.byte[]payload()The payload sent.intreceived()The time received.StringtoString()Prints the immutable valueOutputDataMessagewith attribute values.ImmutableOutputDataMessagewithDevice(Device value)Copy the current immutable object by setting a value for thedeviceattribute.ImmutableOutputDataMessagewithKeepAlive(boolean value)Copy the current immutable object by setting a value for thekeepAliveattribute.ImmutableOutputDataMessagewithPayload(byte... elements)Copy the current immutable object with elements that replace the content ofpayload.ImmutableOutputDataMessagewithReceived(int value)Copy the current immutable object by setting a value for thereceivedattribute.
-
-
-
Method Detail
-
keepAlive
public boolean keepAlive()
Ignore this. For internal use only.- Specified by:
keepAlivein interfaceOutputDataMessage
-
device
@Nullable public Device device()
The sending device.- Specified by:
devicein interfaceOutputDataMessage
-
payload
@Nullable public byte[] payload()
The payload sent.- Specified by:
payloadin interfaceOutputDataMessage
-
received
public int received()
The time received.- Specified by:
receivedin interfaceOutputDataMessage
-
withKeepAlive
public final ImmutableOutputDataMessage withKeepAlive(boolean value)
Copy the current immutable object by setting a value for thekeepAliveattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for keepAlive- Returns:
- A modified copy of the
thisobject
-
withDevice
public final ImmutableOutputDataMessage withDevice(@Nullable Device value)
Copy the current immutable object by setting a value for thedeviceattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for device (can benull)- Returns:
- A modified copy of the
thisobject
-
withPayload
public final ImmutableOutputDataMessage withPayload(@Nullable byte... elements)
Copy the current immutable object with elements that replace the content ofpayload. The array is cloned before being saved as attribute values.- Parameters:
elements- The non-null elements for payload- Returns:
- A modified copy of
thisobject
-
withReceived
public final ImmutableOutputDataMessage withReceived(int value)
Copy the current immutable object by setting a value for thereceivedattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for received- Returns:
- A modified copy of the
thisobject
-
equals
public boolean equals(@Nullable Object another)
This instance is equal to all instances ofImmutableOutputDataMessagethat have equal attribute values.
-
hashCode
public int hashCode()
Computes a hash code from attributes:keepAlive,device,payload,received.
-
toString
public String toString()
Prints the immutable valueOutputDataMessagewith attribute values.
-
copyOf
public static ImmutableOutputDataMessage copyOf(OutputDataMessage instance)
Creates an immutable copy of aOutputDataMessagevalue. 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 OutputDataMessage instance
-
-