Package org.jdbi.v3.core.qualifier
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 java.lang.ObjectATypequalified by a set of qualifier annotations. Two qualified types are equal to each other if theirgetType()andgetQualifiers()properties are equal.
-
-
Field Summary
Fields Modifier and Type Field Description private inthashCodeprivate java.util.Set<java.lang.annotation.Annotation>qualifiersprivate java.lang.reflect.Typetype
-
Constructor Summary
Constructors Modifier Constructor Description privateQualifiedType(java.lang.reflect.Type type, java.util.Set<java.lang.annotation.Annotation> qualifiers)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(java.lang.Object o)java.util.Optional<QualifiedType<?>>flatMapType(java.util.function.Function<java.lang.reflect.Type,java.util.Optional<java.lang.reflect.Type>> mapper)Apply the provided mapping function to the type, and if non-empty is returned, return anOptional<QualifiedType<?>>with the returned type, and the same qualifiers as this instance.java.util.Set<java.lang.annotation.Annotation>getQualifiers()Returns a set of qualifying annotations.java.lang.reflect.TypegetType()Returns the qualified type.inthashCode()booleanhasQualifier(java.lang.Class<? extends java.lang.annotation.Annotation> qualifier)Returns true if this type contains the given qualifier.QualifiedType<?>mapType(java.util.function.Function<java.lang.reflect.Type,java.lang.reflect.Type> mapper)Apply the provided mapping function to the type, and if non-empty is returned, return anOptional<QualifiedType<?>>with the returned type, and the same qualifiers as this instance.static <T> QualifiedType<T>of(java.lang.Class<T> clazz)Creates aQualifiedType<T>for aClass<T>with no qualifiers.static QualifiedType<?>of(java.lang.reflect.Type type)Creates a wildcardQualifiedType<?>for aTypewith no qualifiers.static <T> QualifiedType<T>of(GenericType<T> type)Creates aQualifiedType<T>for aGenericType<T>with no qualifiers.java.lang.StringtoString()QualifiedType<T>with(java.lang.annotation.Annotation... newQualifiers)Returns a QualifiedType that has the same type as this instance, but with only the given qualifiers.QualifiedType<T>with(java.lang.Class<? extends java.lang.annotation.Annotation>... newQualifiers)Returns a QualifiedType that has the same type as this instance, but with only the given qualifiers.QualifiedType<T>withAnnotationClasses(java.lang.Iterable<java.lang.Class<? extends java.lang.annotation.Annotation>> newQualifiers)Creates a QualifiedType with the same type as this instance and new qualifiers.QualifiedType<T>withAnnotations(java.lang.Iterable<? extends java.lang.annotation.Annotation> newQualifiers)Creates a QualifiedType with the same type as this instance and new qualifiers.
-
-
-
Method Detail
-
of
public static <T> QualifiedType<T> of(java.lang.Class<T> clazz)
Creates aQualifiedType<T>for aClass<T>with no qualifiers.- Parameters:
clazz- the unqualified type- Returns:
- the unqualified QualifiedType
- See Also:
to then qualify your type
-
of
public static QualifiedType<?> of(java.lang.reflect.Type type)
Creates a wildcardQualifiedType<?>for aTypewith no qualifiers.- Parameters:
type- the unqualified type- Returns:
- the unqualified QualifiedType
- See Also:
to then qualify your type
-
of
public static <T> QualifiedType<T> of(GenericType<T> type)
Creates aQualifiedType<T>for aGenericType<T>with no qualifiers.- Parameters:
type- the unqualified type- Returns:
- the unqualified QualifiedType
- See Also:
to then qualify your type
-
with
public QualifiedType<T> with(java.lang.annotation.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(java.lang.Class<? extends java.lang.annotation.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:
java.lang.IllegalArgumentException- if any of the given qualifier types have annotation attributes.
-
withAnnotations
public QualifiedType<T> withAnnotations(java.lang.Iterable<? extends java.lang.annotation.Annotation> newQualifiers)
Creates a QualifiedType with the same type as this instance and new qualifiers. Old qualifiers are discarded.- 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(java.lang.Iterable<java.lang.Class<? extends java.lang.annotation.Annotation>> newQualifiers)
Creates a QualifiedType with the same type as this instance and new qualifiers. Old qualifiers are discarded.- 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 java.lang.reflect.Type getType()
Returns the qualified type.- Returns:
- the type being qualified.
-
getQualifiers
public java.util.Set<java.lang.annotation.Annotation> getQualifiers()
Returns a set of qualifying annotations.- Returns:
- the type qualifiers.
-
mapType
public QualifiedType<?> mapType(java.util.function.Function<java.lang.reflect.Type,java.lang.reflect.Type> mapper)
Apply the provided mapping function to the type, and if non-empty is returned, return anOptional<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 java.util.Optional<QualifiedType<?>> flatMapType(java.util.function.Function<java.lang.reflect.Type,java.util.Optional<java.lang.reflect.Type>> mapper)
Apply the provided mapping function to the type, and if non-empty is returned, return anOptional<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(java.lang.Class<? extends java.lang.annotation.Annotation> qualifier)
Returns true if this type contains the given qualifier.- Parameters:
qualifier- qualifier to check for.- Returns:
- true if this instance contains the given qualifier.
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equalsin classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCodein classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-