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:device,payload,received.byte[]payload()The payload sent.java.time.Instantreceived()The time received.StringtoString()Prints the immutable valueOutputDataMessagewith attribute values.ImmutableOutputDataMessagewithDevice(Device value)Copy the current immutable object by setting a value for thedeviceattribute.ImmutableOutputDataMessagewithPayload(byte... elements)Copy the current immutable object with elements that replace the content ofpayload.ImmutableOutputDataMessagewithReceived(java.time.Instant value)Copy the current immutable object by setting a value for thereceivedattribute.
-
-
-
Method Detail
-
device
public Device device()
The sending device.- Specified by:
devicein interfaceOutputDataMessage
-
payload
public byte[] payload()
The payload sent.- Specified by:
payloadin interfaceOutputDataMessage
-
received
public java.time.Instant received()
The time received.- Specified by:
receivedin interfaceOutputDataMessage
-
withDevice
public final ImmutableOutputDataMessage withDevice(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- Returns:
- A modified copy of the
thisobject
-
withPayload
public final ImmutableOutputDataMessage withPayload(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(java.time.Instant value)
Copy the current immutable object by setting a value for thereceivedattribute. A shallow reference 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: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
-
-