java.lang.Object
java.lang.Record
nl.jqno.equalsverifier.internal.reflection.TypeTag

public record TypeTag(Class<?> type, List<TypeTag> genericTypes) extends Record
Represents a generic type, including raw type and generic type parameters.

If the type is not generic, the genericTypes list will be empty.

  • Field Details

    • type

      private final Class<?> type
      The field for the type record component.
    • genericTypes

      private final List<TypeTag> genericTypes
      The field for the genericTypes record component.
    • NULL

      public static final TypeTag NULL
      Null object for TypeTag.
  • Constructor Details

    • TypeTag

      public TypeTag(Class<?> type, TypeTag... genericTypes)
      Constructor.
      Parameters:
      type - The raw type.
      genericTypes - A list of TypeTags for each generic type parameter.
    • TypeTag

      public TypeTag(Class<?> type, List<TypeTag> genericTypes)
      Constructor.
      Parameters:
      type - The raw type.
      genericTypes - A list of TypeTags for each generic type parameter.
  • Method Details

    • of

      public static TypeTag of(Field field, TypeTag enclosingType)
      Resolves a TypeTag from the type of a Field instance, using an enclosing type to determine any generic parameters the field may contain.
      Parameters:
      field - The field to resolve.
      enclosingType - The type that contains the field, used to determine any generic parameters it may contain.
      Returns:
      The TypeTag for the given field.
    • resolve

      private static TypeTag resolve(Type type, Class<?> typeAsClass, TypeTag enclosingType, boolean shortCircuitRecursiveTypeBound)
    • processClass

      private static TypeTag processClass(Class<?> type, List<TypeTag> nestedTags)
    • processParameterizedType

      private static TypeTag processParameterizedType(ParameterizedType type, Class<?> typeAsClass, TypeTag enclosingType, List<TypeTag> nestedTags, boolean shortCircuitRecursiveTypeBound)
    • processGenericArray

      private static TypeTag processGenericArray(GenericArrayType type, Class<?> typeAsClass, TypeTag enclosingType)
    • processWildcard

      private static TypeTag processWildcard(WildcardType type, Class<?> typeAsClass, TypeTag enclosingType, boolean shortCircuitRecursiveTypeBound)
    • processTypeVariable

      private static TypeTag processTypeVariable(TypeVariable<?> type, Class<?> typeAsClass, TypeTag enclosingType, boolean shortCircuitRecursiveTypeBound)
    • buildLookup

      private static Map<String,TypeTag> buildLookup(TypeTag enclosingType)
    • getType

      public <T> Class<T> getType()
      Returns the TypeTag's raw type.
      Type Parameters:
      T - The returned Class will have this generic type.
      Returns:
      The TypeTag's raw type.
    • toString

      public String toString()
      Specified by:
      toString in class Record
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • type

      public Class<?> type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • genericTypes

      public List<TypeTag> genericTypes()
      Returns the value of the genericTypes record component.
      Returns:
      the value of the genericTypes record component