Package org.jboss.jandex
Class WildcardType
- java.lang.Object
-
- org.jboss.jandex.Type
-
- org.jboss.jandex.WildcardType
-
- All Implemented Interfaces:
Descriptor
public class WildcardType extends Type
Represents a generic wildcard. A generic wildcard can have either an upper (extends) or a lower (super) bound. A wildcard declared without a bound ("?") has a default extends bound of "java.lang.Object".- Since:
- 2.0
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classWildcardType.BuilderConvenient builder forWildcardType.
-
Field Summary
Fields Modifier and Type Field Description private Typeboundprivate inthashprivate booleanisExtendsstatic WildcardTypeUNBOUNDEDA wildcard without a bound, an equivalent of?.-
Fields inherited from class org.jboss.jandex.Type
EMPTY_ARRAY
-
Fields inherited from interface org.jboss.jandex.Descriptor
NO_SUBSTITUTION
-
-
Constructor Summary
Constructors Constructor Description WildcardType(Type bound, boolean isExtends)WildcardType(Type bound, boolean isExtends, AnnotationInstance[] annotations)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description WildcardTypeasWildcardType()Casts this type to aWildcardTypeand returns it if the kind isType.Kind.WILDCARD_TYPE.(package private) Typebound()static WildcardType.Builderbuilder()Create a builder of a wildcard type.(package private) TypecopyType(AnnotationInstance[] newAnnotations)(package private) TypecopyType(Type bound)static WildcardTypecreate(Type bound, boolean isExtends)Deprecated.static WildcardTypecreateLowerBound(java.lang.Class<?> lowerBound)Create a new wildcard type with a lower (super) bound.static WildcardTypecreateLowerBound(Type lowerBound)Create a new wildcard type with a lower (super) bound.static WildcardTypecreateUpperBound(java.lang.Class<?> upperBound)Create a new wildcard type with an upper (extends) bound.static WildcardTypecreateUpperBound(Type upperBound)Create a new wildcard type with an upper (extends) bound.booleanequals(java.lang.Object o)Compares thisTypewith another type.TypeextendsBound()Returns the upper bound of this wildcard (e.g.inthashCode()Computes a hash code representing this type.(package private) booleanhasImplicitObjectBound()(package private) booleaninternEquals(java.lang.Object o)(package private) intinternHashCode()(package private) booleanisExtends()Type.Kindkind()Returns the kind of Type this is.DotNamename()Returns the name of this type (or its erasure in case of generic types) as aDotName, using theClass.getName()format.TypesuperBound()Returns the lower bound of this wildcard (e.g.(package private) java.lang.StringtoString(boolean simple)(package private) TypewithoutAnnotations()Returns this type with all type annotations removed.-
Methods inherited from class org.jboss.jandex.Type
addAnnotation, annotation, annotationArray, annotations, annotationsWithRepeatable, appendAnnotations, asArrayType, asClassType, asParameterizedType, asPrimitiveType, asTypeVariable, asTypeVariableReference, asUnresolvedTypeVariable, asVoidType, create, create, createWithAnnotations, descriptor, hasAnnotation, parse, toString
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.jboss.jandex.Descriptor
descriptor
-
-
-
-
Field Detail
-
UNBOUNDED
public static final WildcardType UNBOUNDED
A wildcard without a bound, an equivalent of?.- Since:
- 3.1.0
-
isExtends
private final boolean isExtends
-
bound
private final Type bound
-
hash
private int hash
-
-
Constructor Detail
-
WildcardType
WildcardType(Type bound, boolean isExtends)
-
WildcardType
WildcardType(Type bound, boolean isExtends, AnnotationInstance[] annotations)
-
-
Method Detail
-
create
@Deprecated public static WildcardType create(Type bound, boolean isExtends)
Deprecated.Creates a new wildcard type.- Parameters:
bound- the bound (lower or upper)isExtends- true if the bound is an upper (extends) bound, false if lower (super)- Returns:
- the new instance
- Since:
- 2.1
-
createUpperBound
public static WildcardType createUpperBound(Type upperBound)
Create a new wildcard type with an upper (extends) bound.- Parameters:
upperBound- the upper bound- Returns:
- the new instance
- Since:
- 3.1.0
-
createUpperBound
public static WildcardType createUpperBound(java.lang.Class<?> upperBound)
Create a new wildcard type with an upper (extends) bound.- Parameters:
upperBound- the upper bound- Returns:
- the new instance
- Since:
- 3.1.0
-
createLowerBound
public static WildcardType createLowerBound(Type lowerBound)
Create a new wildcard type with a lower (super) bound.- Parameters:
lowerBound- the lower bound- Returns:
- the new instance
- Since:
- 3.1.0
-
createLowerBound
public static WildcardType createLowerBound(java.lang.Class<?> lowerBound)
Create a new wildcard type with a lower (super) bound.- Parameters:
lowerBound- the lower bound- Returns:
- the new instance
- Since:
- 3.1.0
-
builder
public static WildcardType.Builder builder()
Create a builder of a wildcard type.- Returns:
- the builder
- Since:
- 3.1.0
-
name
public DotName name()
Description copied from class:TypeReturns the name of this type (or its erasure in case of generic types) as aDotName, using theClass.getName()format. Specifically:- for primitive types and the void pseudo-type, the corresponding Java keyword
is returned (
void,boolean,byte,short,int,long,float,double,char); - for class types, the binary name of the class is returned;
- for array types, a string is returned that consists of one or more
[characters corresponding to the number of dimensions of the array type, followed by the element type as a single-character code for primitive types orLbinary.name.of.TheClass;for class types (for example,[Iforint[]or[[Ljava.lang.String;forString[][]); - for parameterized types, the binary name of the generic class is returned
(for example,
java.util.ListforList<String>); - for type variables, the name of the first bound of the type variable is returned,
or
java.lang.Objectfor type variables that have no bound; - for wildcard types, the name of the upper bound is returned,
or
java.lang.Objectif the wildcard type does not have an upper bound (for example,java.lang.Numberfor? extends Number).
- for primitive types and the void pseudo-type, the corresponding Java keyword
is returned (
-
extendsBound
public Type extendsBound()
Returns the upper bound of this wildcard (e.g.SomeTypefor? extends SomeType).Returns
java.lang.Objectif this wildcard declares a lower bound (? super SomeType).- Returns:
- the upper bound, or
Objectif this wildcard has a lower bound
-
superBound
public Type superBound()
Returns the lower bound of this wildcard (e.g.SomeTypefor? super SomeType).Returns
nullif this wildcard declares an upper bound (? extends SomeType).- Returns:
- the lower bound, or
nullif this wildcard has an upper bound
-
bound
Type bound()
-
isExtends
boolean isExtends()
-
hasImplicitObjectBound
boolean hasImplicitObjectBound()
-
asWildcardType
public WildcardType asWildcardType()
Description copied from class:TypeCasts this type to aWildcardTypeand returns it if the kind isType.Kind.WILDCARD_TYPE. Throws an exception otherwise.- Overrides:
asWildcardTypein classType- Returns:
- a
WildcardType
-
copyType
Type copyType(AnnotationInstance[] newAnnotations)
-
withoutAnnotations
Type withoutAnnotations()
Description copied from class:TypeReturns this type with all type annotations removed. The annotations are removed deeply, that is also on the constituent type in case of arrays, on type arguments in case of parameterized types, on the bound in case of wildcard types, etc.- Overrides:
withoutAnnotationsin classType- Returns:
- this type without type annotations
-
equals
public boolean equals(java.lang.Object o)
Description copied from class:TypeCompares thisTypewith another type. A type is equal to another type if it is of the same kind, and all of their fields are equal. This includes annotations, which must be equal as well.
-
hashCode
public int hashCode()
Description copied from class:TypeComputes a hash code representing this type.
-
internEquals
boolean internEquals(java.lang.Object o)
- Overrides:
internEqualsin classType
-
internHashCode
int internHashCode()
- Overrides:
internHashCodein classType
-
-