NullDiscriminator

A NullDiscriminator discriminates any objects that may contain null values to discriminate. The other Discriminators assume that their values to discriminate are not null. This Discriminator follows the Decorator Pattern, decorating another Discriminator by giving it the ability to tolerate null values. jAgg wraps its Discriminators with a NullDiscriminator in order to tolerate null values. A NullDiscriminator treats all null values as equivalent, so it maintains one equivalence class just for the null values. It pulls out all null values into their own equivalence class, then lets its decorated Discriminator discriminate the remainder of the values. Then it adds the "null" equivalence class to the list of the rest of the equivalence classes.

Example

Given the input...

  • {"", "null", null, "not null", "famous", "infamous", null, "not null"}

... a NullDiscriminator(new CharSequenceDiscriminator()) returns the following equivalence classes:

  • {""}
  • {"null"}
  • {"famous"}
  • {"infamous"}
  • {"not null", "not null"}
  • {null, null}