Package io.thestencil.client.api
Class ImmutableEntity<T extends StencilClient.EntityBody>
- java.lang.Object
-
- io.thestencil.client.api.ImmutableEntity<T>
-
- All Implemented Interfaces:
StencilClient.Entity<T>,Serializable
@ParametersAreNonnullByDefault @Generated("org.immutables.processor.ProxyProcessor") @Immutable @CheckReturnValue public final class ImmutableEntity<T extends StencilClient.EntityBody> extends Object implements StencilClient.Entity<T>
Immutable implementation ofStencilClient.Entity.Use the builder to create immutable instances:
ImmutableEntity.builder().- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classImmutableEntity.Builder<T extends StencilClient.EntityBody>Builds instances of typeImmutableEntity.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static <T extends StencilClient.EntityBody>
ImmutableEntity.Builder<T>builder()Creates a builder forImmutableEntity.static <T extends StencilClient.EntityBody>
ImmutableEntity<T>copyOf(StencilClient.Entity<T> instance)Creates an immutable copy of aStencilClient.Entityvalue.booleanequals(Object another)This instance is equal to all instances ofImmutableEntitythat have equal attribute values.TgetBody()StringgetId()StencilClient.EntityTypegetType()inthashCode()Computes a hash code from attributes:id,type,body.StringtoString()Prints the immutable valueEntitywith attribute values.ImmutableEntity<T>withBody(T value)Copy the current immutable object by setting a value for thebodyattribute.ImmutableEntity<T>withId(String value)Copy the current immutable object by setting a value for theidattribute.ImmutableEntity<T>withType(StencilClient.EntityType value)Copy the current immutable object by setting a value for thetypeattribute.
-
-
-
Method Detail
-
getId
public String getId()
- Specified by:
getIdin interfaceStencilClient.Entity<T extends StencilClient.EntityBody>- Returns:
- The value of the
idattribute
-
getType
public StencilClient.EntityType getType()
- Specified by:
getTypein interfaceStencilClient.Entity<T extends StencilClient.EntityBody>- Returns:
- The value of the
typeattribute
-
getBody
public T getBody()
- Specified by:
getBodyin interfaceStencilClient.Entity<T extends StencilClient.EntityBody>- Returns:
- The value of the
bodyattribute
-
withId
public final ImmutableEntity<T> withId(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- Returns:
- A modified copy of the
thisobject
-
withType
public final ImmutableEntity<T> withType(StencilClient.EntityType value)
Copy the current immutable object by setting a value for thetypeattribute. A value equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for type- Returns:
- A modified copy of the
thisobject
-
withBody
public final ImmutableEntity<T> withBody(T value)
Copy the current immutable object by setting a value for thebodyattribute. A shallow reference equality check is used to prevent copying of the same value by returningthis.- Parameters:
value- A new value for body- Returns:
- A modified copy of the
thisobject
-
equals
public boolean equals(@Nullable Object another)This instance is equal to all instances ofImmutableEntitythat have equal attribute values.
-
hashCode
public int hashCode()
Computes a hash code from attributes:id,type,body.
-
toString
public String toString()
Prints the immutable valueEntitywith attribute values.
-
copyOf
public static <T extends StencilClient.EntityBody> ImmutableEntity<T> copyOf(StencilClient.Entity<T> instance)
Creates an immutable copy of aStencilClient.Entityvalue. Uses accessors to get values to initialize the new immutable instance. If an instance is already immutable, it is returned as is.- Type Parameters:
T- generic parameter T- Parameters:
instance- The instance to copy- Returns:
- A copied immutable Entity instance
-
builder
public static <T extends StencilClient.EntityBody> ImmutableEntity.Builder<T> builder()
Creates a builder forImmutableEntity.ImmutableEntity.<T>builder() .id(String) // requiredid.type(io.thestencil.client.api.StencilClient.EntityType) // requiredtype.body(T) // requiredbody.build();- Type Parameters:
T- generic parameter T- Returns:
- A new ImmutableEntity builder
-
-