Package com.telenordigital.nbiot
Class ImmutableMember
- java.lang.Object
-
- com.telenordigital.nbiot.ImmutableMember
-
- All Implemented Interfaces:
Member
@ParametersAreNonnullByDefault @Immutable public final class ImmutableMember extends Object implements Member
Immutable implementation ofMember.Use the builder to create immutable instances:
new ImmutableMember.Builder().
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableMember.BuilderBuilds instances of typeImmutableMember.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static ImmutableMembercopyOf(Member instance)Creates an immutable copy of aMembervalue.booleanequals(Object another)This instance is equal to all instances ofImmutableMemberthat have equal attribute values.inthashCode()Computes a hash code from attributes:userID,role.Stringrole()The user's roleStringtoString()Prints the immutable valueMemberwith attribute values.StringuserID()The user's IDImmutableMemberwithRole(String value)Copy the current immutable object by setting a value for theroleattribute.ImmutableMemberwithUserID(String value)Copy the current immutable object by setting a value for theuserIDattribute.
-
-
-
Method Detail
-
withUserID
public final ImmutableMember withUserID(@Nullable String value)
Copy the current immutable object by setting a value for theuserIDattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for userID (can benull)- Returns:
- A modified copy of the
thisobject
-
withRole
public final ImmutableMember withRole(@Nullable String value)
Copy the current immutable object by setting a value for theroleattribute. An equals check used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for role (can benull)- Returns:
- A modified copy of the
thisobject
-
equals
public boolean equals(@Nullable Object another)
This instance is equal to all instances ofImmutableMemberthat have equal attribute values.
-
hashCode
public int hashCode()
Computes a hash code from attributes:userID,role.
-
toString
public String toString()
Prints the immutable valueMemberwith attribute values.
-
copyOf
public static ImmutableMember copyOf(Member instance)
Creates an immutable copy of aMembervalue. 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 Member instance
-
-