Reflection APIApart from the standard Java API, OOMEGA offers dynamic access to objects whose structure is not known until runtime execution. Accordingly every object has dynamic getter and setter methods. Dynamic access is best shown with a simple example. Let's query for the name of Christian's spouse.
// locate christian - the person object - first
Person christian = (Person) eocSession.execute(
Query(
from(Person.CID),
where(
like(Person.F.firstname(), "Chris*")
)
)
).iterator().next();
// create the fieldpath of interest
FieldPath fieldPath = Person.F.spouse().firstname();
// apply the fieldpath to the object 'christian'
System.out.println(fieldPath + ": " +
christian.get(fieldPath));
This will lead to the following console ouput. spouse.firstname: Mona-Maria Please note, that the fieldpaths can be created dynamically, too. >> Show next feature>> Back to the feature list |