Interface JWildcardType
-
- All Superinterfaces:
JTypeMirror
,JTypeVisitable
public interface JWildcardType extends JTypeMirror
Represents a wildcard type. Such types are converted toJTypeVar
by capture conversion.This implements JTypeMirror for convenience, however, it may only occur as a type argument, and as such some of the behaviour of JTypeMirror is undefined:
subtyping
anderasure
.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default <T,P>
TacceptVisitor(JTypeVisitor<T,P> visitor, P p)
Accept a type visitor, dispatching on this object's runtime type to the correct method of the visitor.default @NonNull JTypeMirror
asLowerBound()
Returns the lower bound, or the bottom type if this is an "extends" wildcard.default @NonNull JTypeMirror
asUpperBound()
Returns the upper bound, or Object if this is a "super" wildcard.@NonNull JTypeMirror
getBound()
Returns the bound.default JTypeMirror
getErasure()
This is implemented for convenience.default boolean
isLowerBound()
Returns true if this is a "super" wildcard, the bound is then a lower bound.default boolean
isUnbounded()
Returns true if this is an "extends" wildcard, with no bound ("?").boolean
isUpperBound()
Returns true if this is an "extends" wildcard, the bound is then an upper bound.default Stream<JMethodSig>
streamMethods(Predicate<? super JMethodSymbol> prefilter)
Returns a stream of method signatures declared in and inherited by this type.JWildcardType
subst(Function<? super SubstVar,? extends @NonNull JTypeMirror> subst)
Replace the type variables occurring in the given type by their image by the given function.JWildcardType
withAnnotations(org.pcollections.PSet<SymbolicValue.SymAnnot> newTypeAnnots)
Returns a type mirror that is equal to this instance but has different type annotations.-
Methods inherited from interface net.sourceforge.pmd.lang.java.types.JTypeMirror
addAnnotation, box, equals, getAsSuper, getConstructors, getSuperTypeSet, getSymbol, getTypeAnnotations, getTypeSystem, isArray, isBottom, isBoxedPrimitive, isClassOrInterface, isConvertibleTo, isFloatingPoint, isGeneric, isGenericTypeDeclaration, isIntegral, isInterface, isNumeric, isParameterizedType, isPrimitive, isPrimitive, isRaw, isReifiable, isSubtypeOf, isTop, isTypeVariable, isVoid, streamDeclaredMethods, toString, unbox
-
-
-
-
Method Detail
-
getBound
@NonNull JTypeMirror getBound()
Returns the bound. Interpretation is given byisUpperBound()
.
-
isUnbounded
default boolean isUnbounded()
Returns true if this is an "extends" wildcard, with no bound ("?").
-
isUpperBound
boolean isUpperBound()
Returns true if this is an "extends" wildcard, the bound is then an upper bound.
-
isLowerBound
default boolean isLowerBound()
Returns true if this is a "super" wildcard, the bound is then a lower bound.
-
asLowerBound
default @NonNull JTypeMirror asLowerBound()
Returns the lower bound, or the bottom type if this is an "extends" wildcard.
-
asUpperBound
default @NonNull JTypeMirror asUpperBound()
Returns the upper bound, or Object if this is a "super" wildcard.
-
getErasure
default JTypeMirror getErasure()
This is implemented for convenience. However, the erasure of a wildcard type is undefined and useless. This is because they can only occur in type arguments, which are erased themselves.- Specified by:
getErasure
in interfaceJTypeMirror
-
streamMethods
default Stream<JMethodSig> streamMethods(Predicate<? super JMethodSymbol> prefilter)
Description copied from interface:JTypeMirror
Returns a stream of method signatures declared in and inherited by this type. Method signatures are created on-demand by this method, they're not reused between calls. This stream does not include constructors.Note: streams are a bit impractical when it comes to configuring the filter. Possibly a specialized API should be introduced. We need to support the use cases of the symbol table, ie filter by name + accessibility + staticity, and also possibly use cases for rules, like getting a method from a known signature. See also
JClassType.getDeclaredMethod(JExecutableSymbol)
, which looks like this. Unifying this API would be nice.- Specified by:
streamMethods
in interfaceJTypeMirror
- Parameters:
prefilter
- Filter selecting symbols for which a signature should be created and yielded by the stream
-
subst
JWildcardType subst(Function<? super SubstVar,? extends @NonNull JTypeMirror> subst)
Description copied from interface:JTypeVisitable
Replace the type variables occurring in the given type by their image by the given function. Substitutions are not applied recursively (ie, is not applied on the result of a substitution).- Specified by:
subst
in interfaceJTypeMirror
- Specified by:
subst
in interfaceJTypeVisitable
- Parameters:
subst
- Substitution function, eg aSubstitution
-
withAnnotations
JWildcardType withAnnotations(org.pcollections.PSet<SymbolicValue.SymAnnot> newTypeAnnots)
Description copied from interface:JTypeMirror
Returns a type mirror that is equal to this instance but has different type annotations. Note that some types ignore this method and return themselves without changing. Eg the null type cannot be annotated.- Specified by:
withAnnotations
in interfaceJTypeMirror
- Parameters:
newTypeAnnots
- New type annotations (not null)- Returns:
- A new type, maybe this one
-
acceptVisitor
default <T,P> T acceptVisitor(JTypeVisitor<T,P> visitor, P p)
Description copied from interface:JTypeVisitable
Accept a type visitor, dispatching on this object's runtime type to the correct method of the visitor.- Specified by:
acceptVisitor
in interfaceJTypeVisitable
- Type Parameters:
T
- Type of result of the visitorP
- Type of data of the visitor
-
-