Class QualifiedType<T>

java.lang.Object
org.jdbi.v3.core.qualifier.QualifiedType<T>
Type Parameters:
T - the type that is qualified

public final class QualifiedType<T> extends Object
A Type qualified by a set of qualifier annotations. Two qualified types are equal to each other if their getType() and getQualifiers() properties are equal.
  • Method Details

    • of

      public static <T> QualifiedType<T> of(Class<T> clazz)
      Creates a QualifiedType<T> for a Class<T> with no qualifiers.
      Parameters:
      clazz - the unqualified type
      Returns:
      the unqualified QualifiedType
      See Also:
    • of

      public static QualifiedType<?> of(Type type)
      Creates a wildcard QualifiedType<?> for a Type with no qualifiers.
      Parameters:
      type - the unqualified type
      Returns:
      the unqualified QualifiedType
      See Also:
    • of

      public static <T> QualifiedType<T> of(GenericType<T> type)
      Creates a QualifiedType<T> for a GenericType<T> with no qualifiers.
      Parameters:
      type - the unqualified type
      Returns:
      the unqualified QualifiedType
      See Also:
    • with

      public QualifiedType<T> with(Annotation... newQualifiers)
      Returns a QualifiedType that has the same type as this instance, but with only the given qualifiers.
      Parameters:
      newQualifiers - the qualifiers for the new qualified type.
      Returns:
      the QualifiedType
    • with

      @SafeVarargs public final QualifiedType<T> with(Class<? extends Annotation>... newQualifiers)
      Returns a QualifiedType that has the same type as this instance, but with only the given qualifiers.
      Parameters:
      newQualifiers - the qualifiers for the new qualified type.
      Returns:
      the QualifiedType
      Throws:
      IllegalArgumentException - if any of the given qualifier types have annotation attributes.
    • withAnnotations

      public QualifiedType<T> withAnnotations(Iterable<? extends Annotation> newQualifiers)
      Parameters:
      newQualifiers - the qualifiers for the new qualified type.
      Returns:
      a QualifiedType that has the same type as this instance, but with only the given qualifiers.
    • withAnnotationClasses

      public QualifiedType<T> withAnnotationClasses(Iterable<Class<? extends Annotation>> newQualifiers)
      Parameters:
      newQualifiers - the qualifiers for the new qualified type.
      Returns:
      a QualifiedType that has the same type as this instance, but with only the given qualifiers.
    • getType

      public Type getType()
      Returns:
      the type being qualified
    • getQualifiers

      public Set<Annotation> getQualifiers()
      Returns:
      the type qualifiers.
    • mapType

      public QualifiedType<?> mapType(Function<Type,Type> mapper)
      Apply the provided mapping function to the type, and if non-empty is returned, return an Optional<QualifiedType<?>> with the returned type, and the same qualifiers as this instance.
      Parameters:
      mapper - a mapping function to apply to the type
      Returns:
      an optional qualified type with the mapped type and the same qualifiers
    • flatMapType

      public Optional<QualifiedType<?>> flatMapType(Function<Type,Optional<Type>> mapper)
      Apply the provided mapping function to the type, and if non-empty is returned, return an Optional<QualifiedType<?>> with the returned type, and the same qualifiers as this instance.
      Parameters:
      mapper - a mapping function to apply to the type
      Returns:
      an optional qualified type with the mapped type and the same qualifiers
    • hasQualifier

      public boolean hasQualifier(Class<? extends Annotation> qualifier)
      Parameters:
      qualifier - qualifier to check for
      Returns:
      true if this instance contains the given qualifier
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object