public abstract class AbstractBeanEntity extends AbstractEntity
Abstract entity implementation that uses bean methods.
Modifier and Type | Class and Description |
---|---|
static class |
AbstractBeanEntity.BeanAttributeGetter
Internal utility class - do not use.
|
protected static class |
AbstractBeanEntity.BeanEntityLayout |
id, type
Modifier | Constructor and Description |
---|---|
protected |
AbstractBeanEntity(AbstractBeanEntity.BeanEntityLayout bel,
EntityType typ,
long id)
Construct a bean entity.
|
Modifier and Type | Method and Description |
---|---|
java.util.Set<java.lang.String> |
getAttributeNames()
Get the names of the attributes in this entity.
|
java.util.Collection<Attribute<?>> |
getAttributes()
Get the attribute-value pairs.
|
boolean |
getBoolean(TypedName<java.lang.Boolean> name)
Get the value of a attr that contains a boolean.
|
double |
getDouble(TypedName<java.lang.Double> name)
Get the value of a attr that contains a double.
|
int |
getInteger(TypedName<java.lang.Integer> name)
Get the value of a attr that contains a int.
|
long |
getLong(TypedName<java.lang.Long> name)
Get the value of a attribute that contains a long.
|
java.util.Set<TypedName<?>> |
getTypedAttributeNames()
Get the attributes in this entity.
|
boolean |
hasAttribute(java.lang.String name)
Check if the entity has a field with a particular name.
|
boolean |
hasAttribute(TypedName<?> name)
Check if the entity has a attribute.
|
protected static AbstractBeanEntity.BeanEntityLayout |
makeLayout(java.lang.Class<? extends AbstractBeanEntity> type) |
java.lang.Object |
maybeGet(java.lang.String attr)
Get the value of a possibly-missing attribute by name.
|
<T> T |
maybeGet(TypedName<T> name)
Get the value of a possibly-missing attribute.
|
asMap, describeTo, equals, get, get, getId, getType, hashCode, toString
protected AbstractBeanEntity(AbstractBeanEntity.BeanEntityLayout bel, EntityType typ, long id)
Construct a bean entity.
bel
- The layout (from makeLayout(Class)
).typ
- The entity typeid
- The entity ID.public java.util.Set<TypedName<?>> getTypedAttributeNames()
Entity
Get the attributes in this entity.
public java.util.Set<java.lang.String> getAttributeNames()
AbstractEntity
Get the names of the attributes in this entity.
Delegates to Entity.getTypedAttributeNames()
and extracts the names.
getAttributeNames
in interface Entity
getAttributeNames
in class AbstractEntity
public java.util.Collection<Attribute<?>> getAttributes()
AbstractEntity
Get the attribute-value pairs.
Delegates to Entity.getTypedAttributeNames()
and extracts the names.
getAttributes
in interface Entity
getAttributes
in class AbstractEntity
public boolean hasAttribute(java.lang.String name)
Entity
Check if the entity has a field with a particular name.
name
- The field name to look for.true
if the entity has a field named name
.public boolean hasAttribute(TypedName<?> name)
AbstractEntity
Check if the entity has a attribute.
This implementation delegates to Entity.hasAttribute(String)
hasAttribute
in interface Entity
hasAttribute
in class AbstractEntity
name
- The attribute name to look for.true
if the entity contains attribute
and the value is of the associated type.@Nullable public java.lang.Object maybeGet(java.lang.String attr)
Entity
Get the value of a possibly-missing attribute by name.
attr
- The attribute name.null
if it is not present.@Nullable public <T> T maybeGet(TypedName<T> name)
AbstractEntity
Get the value of a possibly-missing attribute.
This implementation delegates to Entity.maybeGet(String)
and checks the type.
maybeGet
in interface Entity
maybeGet
in class AbstractEntity
name
- The attribute name.null
if it is not present.public long getLong(TypedName<java.lang.Long> name)
AbstractEntity
Get the value of a attribute that contains a long.
This implementation delegates to AbstractEntity.get(TypedName)
.
getLong
in interface Entity
getLong
in class AbstractEntity
name
- The attribute name.public double getDouble(TypedName<java.lang.Double> name)
AbstractEntity
Get the value of a attr that contains a double.
This implementation delegates to AbstractEntity.get(TypedName)
.
getDouble
in interface Entity
getDouble
in class AbstractEntity
name
- The attribute name.public int getInteger(TypedName<java.lang.Integer> name)
AbstractEntity
Get the value of a attr that contains a int.
This implementation delegates to AbstractEntity.get(TypedName)
.
getInteger
in interface Entity
getInteger
in class AbstractEntity
name
- The attribute name.public boolean getBoolean(TypedName<java.lang.Boolean> name)
AbstractEntity
Get the value of a attr that contains a boolean.
This implementation delegates to AbstractEntity.get(TypedName)
.
getBoolean
in interface Entity
getBoolean
in class AbstractEntity
name
- The attribute name.protected static AbstractBeanEntity.BeanEntityLayout makeLayout(java.lang.Class<? extends AbstractBeanEntity> type)