-
- All Implemented Interfaces:
-
dev.thecodewarrior.mirror.type.TypeMirror
public interface WildcardMirror implements TypeMirror
The type of mirror used to represent wildcard types.
-
-
Method Summary
Modifier and Type Method Description abstract WildcardMirrorwithBounds(List<TypeMirror> upperBounds, List<TypeMirror> lowerBounds)Specialize this wildcard with the provided upper and lower bounds. abstract WildcardMirrorwithTypeAnnotations(List<Annotation> annotations)Creates a copy of this type mirror that has been specialized to have the passed Type Annotations. abstract WildcardTypegetCoreType()The Java Core Reflection type this mirror represents abstract AnnotatedWildcardTypegetCoreAnnotatedType()The Java Core Reflection annotated type this mirror represents. abstract WildcardMirrorgetRaw()The mirror representing this type without any generic specialization abstract List<TypeMirror>getLowerBounds()? super Torout T.abstract TypeMirrorgetLowerBound()? super Torout T.abstract List<TypeMirror>getUpperBounds()? extends Torin T.abstract TypeMirrorgetUpperBound()? extends Torin T.abstract Class<?>getErasure()The JVM erasure of this type. abstract AnnotationListgetTypeAnnotations()The type annotations present on this type. -
-
Method Detail
-
withBounds
abstract WildcardMirror withBounds(List<TypeMirror> upperBounds, List<TypeMirror> lowerBounds)
Specialize this wildcard with the provided upper and lower bounds. If the upper and lower bounds aren't
-
withTypeAnnotations
abstract WildcardMirror withTypeAnnotations(List<Annotation> annotations)
Creates a copy of this type mirror that has been specialized to have the passed Type Annotations. Type annotations on this mirror will not carry over to the resulting mirror.
Note that are not the annotations present on the class declaration, they are the annotations present on the use of the type.
-
getCoreType
abstract WildcardType getCoreType()
The Java Core Reflection type this mirror represents
-
getCoreAnnotatedType
abstract AnnotatedWildcardType getCoreAnnotatedType()
The Java Core Reflection annotated type this mirror represents.
!!NOTE!! The JVM implementations of
AnnotatedTypedon't implementequalsorhashCode, so they will equal neither each other nor this. If you need these methods pass any annotated type through Mirror.toCanonical.
-
getRaw
abstract WildcardMirror getRaw()
The mirror representing this type without any generic specialization
-
getLowerBounds
abstract List<TypeMirror> getLowerBounds()
? super Torout T. The lowermost type in the hierarchy that is valid. Any valid type must be a supertype ofT. The current language spec only allows for one, but the Core Reflection API supports multiple for future-proofing reasons.In plain english, a lower bounded wildcard represents "somewhere I can put a < bound >", as opposed to upper bounded wildcards being "some kind of < bound >".
For `? super AbstractList` - Object - Valid - `Object myVar = myAbstractList;` compiles - List - Valid - `List myVar = myAbstractList;` compiles * AbstractList - Valid - `AbstractList myVar = myAbstractList;` compiles - ArrayList - Invalid - `ArrayList myVar = myAbstractList;` does not compile
-
getLowerBound
abstract TypeMirror getLowerBound()
? super Torout T. The lowermost type in the hierarchy that is valid. Any valid type must be a supertype ofT. This is a shorthand for the first element of lowerBounds, if it exists, as currently that is the only one supported by the language.In plain english, a lower bounded wildcard represents "somewhere I can put a < bound >", as opposed to upper bounded wildcards being "some kind of < bound >".
For `? super AbstractList` - Object - Valid - `Object myVar = myAbstractList;` compiles - List - Valid - `List myVar = myAbstractList;` compiles * AbstractList - Valid - `AbstractList myVar = myAbstractList;` compiles - ArrayList - Invalid - `ArrayList myVar = myAbstractList;` does not compile
-
getUpperBounds
abstract List<TypeMirror> getUpperBounds()
? extends Torin T. The uppermost type in the hierarchy that is valid. Any valid type must be a subclass of and implement the interfaces in upperBounds. The current language spec only allows for one, but the Core Reflection API supports multiple for future-proofing reasons.In plain english, an upper bounded wildcard represents "some kind of < bound >", as opposed to lower bounded wildcards being "somewhere I can put a < bound >".
For `? extends List` - Object - Invalid - `public List foo() { return myObject; }` does not compile * List - Valid - `public List foo() { return myList; }` compiles - AbstractList - Valid - `public List foo() { return myAbstractList; }` compiles - ArrayList - Valid - `public List foo() { return myArrayList; }` compiles
-
getUpperBound
abstract TypeMirror getUpperBound()
? extends Torin T. The uppermost type in the hierarchy that is valid. Any valid type must be a subclass of or implement the classes in upperBounds. This is a shorthand for the first element of upperBounds, if it exists, as currently that is the only one supported by the language.In plain english, an upper bounded wildcard represents "some kind of < bound >", as opposed to lower bounded wildcards being "somewhere I can put a < bound >".
For `? extends List` - Object - Invalid - `public List foo() { return myObject; }` does not compile * List - Valid - `public List foo() { return myList; }` compiles - AbstractList - Valid - `public List foo() { return myAbstractList; }` compiles - ArrayList - Valid - `public List foo() { return myArrayList; }` compiles
-
getErasure
abstract Class<?> getErasure()
The JVM erasure of this type.
-
getTypeAnnotations
abstract AnnotationList getTypeAnnotations()
The type annotations present on this type. These are not the annotations present on the declaration, they are the annotations present on the use of the type.
-
-
-
-