public abstract class EntityBuilder
extends java.lang.Object
Base class for entity builders. The standard implementation is BasicEntityBuilder
, which can be created with Entities.newBuilder(EntityType)
.
Modifier and Type | Field and Description |
---|---|
protected long |
id |
protected boolean |
idSet |
protected EntityType |
type |
Modifier | Constructor and Description |
---|---|
protected |
EntityBuilder(EntityType typ)
Construct a new entity builder.
|
Modifier and Type | Method and Description |
---|---|
abstract Entity |
build()
Build the entity.
|
abstract EntityBuilder |
clearAttribute(TypedName<?> name)
Clear an attribute.
|
EntityBuilder |
reset()
Reset this entity builder, clearing all properties except the entity type.
|
<T> EntityBuilder |
setAttribute(Attribute<T> attr)
Set an attribute in the entity.
|
abstract <T> EntityBuilder |
setAttribute(TypedName<T> name,
T val)
Set an attribute in the entity.
|
EntityBuilder |
setDoubleAttribute(TypedName<java.lang.Double> name,
double val)
Set an attribute in the entity.
|
EntityBuilder |
setId(long eid)
Set the entity id.
|
EntityBuilder |
setLongAttribute(TypedName<java.lang.Long> name,
long val)
Set an attribute in the entity.
|
protected final EntityType type
protected long id
protected boolean idSet
protected EntityBuilder(EntityType typ)
Construct a new entity builder.
typ
- The entity type.public EntityBuilder setId(long eid)
Set the entity id.
eid
- The entity id.public abstract <T> EntityBuilder setAttribute(TypedName<T> name, T val)
Set an attribute in the entity.
name
- The name of the attribute to set.val
- The attribute value.T
- The attribute type.NoSuchAttributeException
- if the specified attribute is not supported by this entity.public <T> EntityBuilder setAttribute(Attribute<T> attr)
Set an attribute in the entity.
attr
- The attribute to set.T
- The attribute type.NoSuchAttributeException
- if the specified attribute is not supported by this entity.public EntityBuilder setLongAttribute(TypedName<java.lang.Long> name, long val)
Set an attribute in the entity.
name
- The name of the attribute to set.val
- The attribute value.NoSuchAttributeException
- if the specified attribute is not supported by this entity.public EntityBuilder setDoubleAttribute(TypedName<java.lang.Double> name, double val)
Set an attribute in the entity.
name
- The name of the attribute to set.val
- The attribute value.NoSuchAttributeException
- if the specified attribute is not supported by this entity.public abstract EntityBuilder clearAttribute(TypedName<?> name)
Clear an attribute.
name
- The name of the attribute to clear.@OverridingMethodsMustInvokeSuper public EntityBuilder reset()
Reset this entity builder, clearing all properties except the entity type.
public abstract Entity build()
Build the entity.