public class AttributeEntityUtility extends Object
Appearance app = new Appearance();
MyEntityInterface mif = (MyEntityInterface) AttributeEntityFactory
.createAttributeEntity(MyEntityInterface.class, "myEntityName", app);
mif.setAttribute1(value1);
mif.setAttribute2(value2);
And use it to read the values from an EffectiveAppearance:
EffectiveAppearance ea = ...
MyEntityInterface mif = (MyEntityInterface) AttributeEntityFactory.createAttributeEntity(MyEntityInterface.class, "myEntityName", ea);
value1 = mif.getAttribute1();
value2 = mif.getAttribute2();
Note: Instances that act on Appearance
s can call set- and
get-Methods, instances acting on EffectiveAppearance
s can ONLY use
get-Methods.
The given prefix is used as a name prefix for the single attributes. i.e. in the above example the attribute "attribute1" is stored in the Appearance(s) as setAttribute("myEntityName:attribute1"); To read the values again one needs to use the same prefix as used while writing.
Modifier and Type | Method and Description |
---|---|
static AttributeEntity |
createAttributeEntity(Class clazz,
String prefix,
Appearance a,
boolean readDefaults)
Create an implementation of the
AttributeEntity for reading from
and/or writing to an Appearance - writes tag to the appearance. |
static AttributeEntity |
createAttributeEntity(Class clazz,
String prefix,
EffectiveAppearance ea)
Create an implementation of the
AttributeEntity for reading from an
EffectiveAppearance . |
static AttributeEntity |
getAttributeEntity(Class clazz,
String prefix,
Appearance a,
boolean readDefaults)
Create an implementation of the
AttributeEntity for reading from
and/or writing to an Appearance - this does not tag the appearance. |
static boolean |
hasAttributeEntity(Class clazz,
String prefix,
Appearance a) |
static boolean |
hasAttributeEntity(Class clazz,
String prefix,
EffectiveAppearance eap)
returns true if the appearance is tagged with the given class or if
1.
|
public static AttributeEntity createAttributeEntity(Class clazz, String prefix, Appearance a, boolean readDefaults)
AttributeEntity
for reading from
and/or writing to an Appearance
- writes tag to the appearance.public static AttributeEntity getAttributeEntity(Class clazz, String prefix, Appearance a, boolean readDefaults)
AttributeEntity
for reading from
and/or writing to an Appearance
- this does not tag the appearance.public static AttributeEntity createAttributeEntity(Class clazz, String prefix, EffectiveAppearance ea)
AttributeEntity
for reading from an
EffectiveAppearance
.public static boolean hasAttributeEntity(Class clazz, String prefix, EffectiveAppearance eap)
clazz
- prefix
- eap
- public static boolean hasAttributeEntity(Class clazz, String prefix, Appearance a)