Package com.telenordigital.nbiot
Class ImmutableDevice.Builder
- java.lang.Object
-
- com.telenordigital.nbiot.ImmutableDevice.Builder
-
- Enclosing class:
- ImmutableDevice
@NotThreadSafe public static final class ImmutableDevice.Builder extends Object
Builds instances of typeImmutableDevice. Initialize attributes and then invoke thebuild()method to create an immutable instance.Builderis not thread-safe and generally should not be stored in a field or collection, but instead used immediately to create instances.
-
-
Constructor Summary
Constructors Constructor Description Builder()Creates a builder forImmutableDeviceinstances.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableDevicebuild()Builds a newImmutableDevice.ImmutableDevice.BuildercollectionID(String collectionID)Initializes the value for thecollectionIDattribute.ImmutableDevice.Builderfrom(Device instance)Fill a builder with attribute values from the providedDeviceinstance.ImmutableDevice.Builderid(String id)Initializes the value for theidattribute.ImmutableDevice.Builderimei(String imei)Initializes the value for theimeiattribute.ImmutableDevice.Builderimsi(String imsi)Initializes the value for theimsiattribute.ImmutableDevice.BuilderputAllTags(Map<String,? extends String> tags)Put all mappings from the specified map as entries totagsmap.ImmutableDevice.BuilderputTags(String key, String value)Put one entry to thetagsmap.ImmutableDevice.BuilderputTags(Map.Entry<String,? extends String> entry)Put one entry to thetagsmap.ImmutableDevice.Buildertags(Map<String,? extends String> tags)Sets or replaces all mappings from the specified map as entries for thetagsmap.
-
-
-
Constructor Detail
-
Builder
public Builder()
Creates a builder forImmutableDeviceinstances.
-
-
Method Detail
-
from
public final ImmutableDevice.Builder from(Device instance)
Fill a builder with attribute values from the providedDeviceinstance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values. Collection elements and entries will be added, not replaced.- Parameters:
instance- The instance from which to copy values- Returns:
thisbuilder for use in a chained invocation
-
id
public final ImmutableDevice.Builder id(@Nullable String id)
Initializes the value for theidattribute.- Parameters:
id- The value for id (can benull)- Returns:
thisbuilder for use in a chained invocation
-
collectionID
public final ImmutableDevice.Builder collectionID(@Nullable String collectionID)
Initializes the value for thecollectionIDattribute.- Parameters:
collectionID- The value for collectionID (can benull)- Returns:
thisbuilder for use in a chained invocation
-
imei
public final ImmutableDevice.Builder imei(@Nullable String imei)
Initializes the value for theimeiattribute.- Parameters:
imei- The value for imei (can benull)- Returns:
thisbuilder for use in a chained invocation
-
imsi
public final ImmutableDevice.Builder imsi(@Nullable String imsi)
Initializes the value for theimsiattribute.- Parameters:
imsi- The value for imsi (can benull)- Returns:
thisbuilder for use in a chained invocation
-
putTags
public final ImmutableDevice.Builder putTags(String key, String value)
Put one entry to thetagsmap.- Parameters:
key- The key in the tags mapvalue- The associated value in the tags map- Returns:
thisbuilder for use in a chained invocation
-
putTags
public final ImmutableDevice.Builder putTags(Map.Entry<String,? extends String> entry)
Put one entry to thetagsmap. Nulls are not permitted- Parameters:
entry- The key and value entry- Returns:
thisbuilder for use in a chained invocation
-
tags
public final ImmutableDevice.Builder tags(@Nullable Map<String,? extends String> tags)
Sets or replaces all mappings from the specified map as entries for thetagsmap. Nulls are not permitted as keys or values, but parameter itself can be null- Parameters:
tags- The entries that will be added to the tags map- Returns:
thisbuilder for use in a chained invocation
-
putAllTags
public final ImmutableDevice.Builder putAllTags(Map<String,? extends String> tags)
Put all mappings from the specified map as entries totagsmap. Nulls are not permitted- Parameters:
tags- The entries that will be added to the tags map- Returns:
thisbuilder for use in a chained invocation
-
build
public ImmutableDevice build()
Builds a newImmutableDevice.- Returns:
- An immutable instance of Device
- Throws:
IllegalStateException- if any required attributes are missing
-
-