Package com.telenordigital.nbiot
Class ImmutableCollection
- java.lang.Object
-
- com.telenordigital.nbiot.ImmutableCollection
-
- All Implemented Interfaces:
Collection
@ParametersAreNonnullByDefault @Immutable public final class ImmutableCollection extends Object implements Collection
Immutable implementation ofCollection.Use the builder to create immutable instances:
new ImmutableCollection.Builder().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableCollection.BuilderBuilds instances of typeImmutableCollection.-
Nested classes/interfaces inherited from interface com.telenordigital.nbiot.Collection
Collection.CollectionList
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImmutableCollectioncopyOf(Collection instance)Creates an immutable copy of aCollectionvalue.booleanequals(Object another)This instance is equal to all instances ofImmutableCollectionthat have equal attribute values.inthashCode()Computes a hash code from attributes:id,teamID,tags.Stringid()The collection's IDMap<String,String>tags()Collection tags.StringteamID()The team's IDStringtoString()Prints the immutable valueCollectionwith attribute values.ImmutableCollectionwithId(String value)Copy the current immutable object by setting a value for theidattribute.ImmutableCollectionwithTags(Map<String,? extends String> entries)Copy the current immutable object by replacing thetagsmap with the specified map.ImmutableCollectionwithTeamID(String value)Copy the current immutable object by setting a value for theteamIDattribute.
-
-
-
Method Detail
-
id
@Nullable public String id()
The collection's ID- Specified by:
idin interfaceCollection
-
teamID
@Nullable public String teamID()
The team's ID- Specified by:
teamIDin interfaceCollection
-
tags
@Nullable public Map<String,String> tags()
Collection tags.- Specified by:
tagsin interfaceCollection
-
withId
public final ImmutableCollection 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
-
withTeamID
public final ImmutableCollection withTeamID(@Nullable String value)
Copy the current immutable object by setting a value for theteamIDattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for teamID (can benull)- Returns:
- A modified copy of the
thisobject
-
withTags
public final ImmutableCollection 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 ofImmutableCollectionthat have equal attribute values.
-
hashCode
public int hashCode()
Computes a hash code from attributes:id,teamID,tags.
-
toString
public String toString()
Prints the immutable valueCollectionwith attribute values.
-
copyOf
public static ImmutableCollection copyOf(Collection instance)
Creates an immutable copy of aCollectionvalue. 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 Collection instance
-
-