Class EqualityValidator

java.lang.Object
com.io7m.jequality.validator.EqualityValidator

public final class EqualityValidator extends Object

A validator that examines a class and tries to determine whether the class uses reference equality or structural equality.

A class is assumed to use reference equality if neither it nor any of its supertypes overrides the equals method provided by Object.

A class is assumed to use structural equality if it overrides the equals method provided by Object.

The equals method of a class is assumed to be consistent with the hashCode method if they are both defined in the same class. Checking for true consistency is obviously undecidable.

A class is valid if it uses the correct type of equality relative to its annotations (EqualityReference, EqualityStructural).

  • Method Details

    • validateClass

      public static ValidatorResult validateClass(Class<?> c, AnnotationRequirement requirement, boolean check_hashcode)
      Validate the given class according to the annotation requirements.
      Parameters:
      c - The class
      requirement - The annotation requirements
      check_hashcode - true if hashCode methods should be checked for consistency
      Returns:
      true if the class is valid according to its annotations