Package io.thestencil.persistence.api
Class ImmutableEntity.Builder<T extends ZoePersistence.EntityBody>
- java.lang.Object
-
- io.thestencil.persistence.api.ImmutableEntity.Builder<T>
-
- Enclosing class:
- ImmutableEntity<T extends ZoePersistence.EntityBody>
@NotThreadSafe public static final class ImmutableEntity.Builder<T extends ZoePersistence.EntityBody> extends Object
Builds instances of typeImmutableEntity. 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.
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ImmutableEntity.Builder<T>body(T body)Initializes the value for thebodyattribute.ImmutableEntity<T>build()Builds a newImmutableEntity.ImmutableEntity.Builder<T>from(ZoePersistence.Entity<T> instance)Fill a builder with attribute values from the providedEntityinstance.ImmutableEntity.Builder<T>id(String id)Initializes the value for theidattribute.ImmutableEntity.Builder<T>type(ZoePersistence.EntityType type)Initializes the value for thetypeattribute.
-
-
-
Method Detail
-
from
@CanIgnoreReturnValue public final ImmutableEntity.Builder<T> from(ZoePersistence.Entity<T> instance)
Fill a builder with attribute values from the providedEntityinstance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values.- Parameters:
instance- The instance from which to copy values- Returns:
thisbuilder for use in a chained invocation
-
id
@CanIgnoreReturnValue public final ImmutableEntity.Builder<T> id(String id)
Initializes the value for theidattribute.- Parameters:
id- The value for id- Returns:
thisbuilder for use in a chained invocation
-
type
@CanIgnoreReturnValue public final ImmutableEntity.Builder<T> type(ZoePersistence.EntityType type)
Initializes the value for thetypeattribute.- Parameters:
type- The value for type- Returns:
thisbuilder for use in a chained invocation
-
body
@CanIgnoreReturnValue public final ImmutableEntity.Builder<T> body(T body)
Initializes the value for thebodyattribute.- Parameters:
body- The value for body- Returns:
thisbuilder for use in a chained invocation
-
build
public ImmutableEntity<T> build()
Builds a newImmutableEntity.- Returns:
- An immutable instance of Entity
- Throws:
IllegalStateException- if any required attributes are missing
-
-