PropertiesDiscriminator

A PropertiesDiscriminator discriminates any objects based on values from a given set of property names. jAgg uses a PropertiesDiscriminator when grouping by certain property names during aggregation. This Discriminator discriminates objects by calling the object's methods that correspond to the property names and then discriminating on the results of those method calls. It delegates to other Discriminators, based on the return types of those methods.

A PropertiesDiscriminator is used by a DiscriminableDiscriminator, after it determines the list of properties to discriminate.

Example

Given the class...

public class Widget
{
    private int a;
    private int b;
    public Widget(int a, int b) {this.a = a; this.b = b;}
    public int getA() { return a; }
    public int getB() { return b; }
    public int getResult() { return a + b; }
}
            

... and the input...

  • {new Widget(1, 2), new Widget(2, 1), new Widget(5, 0), new Widget(5, 1), new Widget(3, 3), new Widget(0, 0), new Widget(4, 4), new Widget(5, 4)}

... a PropertiesDiscriminator(Arrays.asList("result")) returns the following equivalence classes:

  • {Widget(5, 0)} - result 5
  • {Widget(0, 0)} - result 0
  • {Widget(4, 4)} - result 8
  • {Widget(5, 4)} - result 9
  • {Widget(1, 2), Widget(2, 1)} - result 3
  • {Widget(5, 1), Widget(3, 3)} - result 6