Class FieldInvariants

java.lang.Object
org.checkerframework.framework.util.FieldInvariants

public class FieldInvariants extends Object
Represents field invariants, which the user states by writing @FieldInvariant. Think of this as a set of (field, qualifier) pairs.

A FieldInvariants object may be malformed (inconsistent number of fields and qualifiers). In this case, the BaseTypeVisitor will issue an error.

  • Constructor Details

    • FieldInvariants

      public FieldInvariants(List<String> fields, List<AnnotationMirror> qualifiers)
      Creates a new FieldInvariants object. The result is well-formed if length of qualifiers is either 1 or equal to length of fields.
      Parameters:
      fields - list of fields
      qualifiers - list of qualifiers
    • FieldInvariants

      public FieldInvariants(FieldInvariants other, List<String> fields, List<AnnotationMirror> qualifiers)
      Creates a new object with all the invariants in other, plus those specified by fields and qualifiers. The result is well-formed if length of qualifiers is either 1 or equal to length of fields.
      Parameters:
      other - other invariant object, may be null
      fields - list of fields
      qualifiers - list of qualifiers
  • Method Details

    • getFields

      public List<String> getFields()
      The simple names of the fields that have a qualifier. May contain duplicates.
    • getQualifiersFor

      public List<AnnotationMirror> getQualifiersFor(CharSequence field)
      Returns a list of qualifiers for field. If field has no qualifiers, returns an empty list.
      Parameters:
      field - simple field name
      Returns:
      a list of qualifiers for field, possibly empty
    • isWellFormed

      public boolean isWellFormed()
      Returns true if there is a qualifier for each field in fields.
      Returns:
      true if there is a qualifier for each field in fields
    • isSuperInvariant

      public DiagMessage isSuperInvariant(FieldInvariants superInvar, AnnotatedTypeFactory factory)
      Returns null if superInvar is a super invariant, otherwise returns the error message.
      Parameters:
      superInvar - the value to check for being a super invariant
      factory - the type factory
      Returns:
      null if superInvar is a super invariant, otherwise returns the error message