Skip to content
Ricardo Pescuma Domenecci edited this page Jul 27, 2013 · 1 revision

The attributes are a kind of hight level reflection. They know how to get/set itself, how to add/remove listeners to changes and a few more tricks. They are the Model component, or a Model wrapper, if you prefer. More details here.

The implemented types of attributes are:

Reflection

Uses java reflection to handle and Object or a Class. The main player is the ReflectionGroup, that can extract ReflectionAttribute objects for all the fields.

To create one, just pass the needed Object or Class to a ReflectionGroup constructor:

new ReflectionGroup(obj)

it create attribute to all instance variables of obj and all superclasses (and will ignore all static attributes).

If you want a list of all static attributes of a Class, you can use:

new ReflectionGroup(MyClass.class)

It also allows some configuration, that is made through an instance of ReflectionData passed as second parameter in the constructor.

There are also some annotations that can be added to the model and that ReflectionAttribute can use. They are:

  • @CompareWith (not used yet)
  • @NotNull
  • @Range

Map

Uses a map containing attributes names as keys and attribute values as values. It will guess the type based on the attribute already in the map.

To use it just pass a Map to the constructor of MapGroup:

new MapGroup(map)

It does not have any other parameter right now.

Custom

You also can create custom attributes, based in one of the base classes created for that:

  • AbstractAttribute - read-write attribute without a listener
  • AbstractListenerAttribute - read-write attribute with a listener
  • AbstractReadOnlyAttribute - read-only attribute

Clone this wiki locally