jAgg supports discriminating objects that have properties such as Integers and Strings, with built-in Discriminators. But what if the property is an object type defined outside of Java and jAgg, e.g. Widget? How is a Widget to be discriminated? It can only be discriminated if it implements the Discriminable interface.

Discriminable Interface

The Discriminable interface is to be implemented by the user's own object types that are properties of the main object type to be discriminated. It is not necessary for such a type to implement Discriminable, because jAgg will fall back on sorting if it cannot discriminate an object type that it encounters. But it is necessary to complete the multiset discrimination. This interface allows multiset discrimination to take place for any object types. The Discriminable interface defines only one method:

  • public List<String> getDiscriminableProperties() - Return a List of property names that can be used to discriminate objects of this type.

jAgg creates and uses a DiscriminableDiscriminator to discriminate objects that are Discriminable. The DiscriminableDiscriminator calls the above method to obtain the list of properties. Then it creates and uses a PropertiesDiscriminator to perform the actual discrimination on the object type.