public abstract class EntityBuilder extends 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 |
setId(long eid)
Set the entity id.
|
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 attributre to set.T
- The attribute type.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.