Package org.aspectj.weaver.patterns
Class WildTypePattern
java.lang.Object
org.aspectj.weaver.patterns.PatternNode
org.aspectj.weaver.patterns.TypePattern
org.aspectj.weaver.patterns.WildTypePattern
- All Implemented Interfaces:
IHasPosition,IHasSourceLocation
The PatternParser always creates WildTypePatterns for type patterns in pointcut expressions (apart from *, which is sometimes
directly turned into TypePattern.ANY). resolveBindings() tries to work out what we've really got and turn it into a type pattern
that we can use for matching. This will normally be either an ExactTypePattern or a WildTypePattern.
Here's how the process pans out for various generic and parameterized patterns: (see GenericsWildTypePatternResolvingTestCase)
Foo where Foo exists and is generic Parser creates WildTypePattern namePatterns={Foo} resolveBindings resolves Foo to RT(Foo -
raw) return ExactTypePattern(LFoo;)
Foo<String> where Foo exists and String meets the bounds Parser creates WildTypePattern namePatterns = {Foo},
typeParameters=WTP{String} resolveBindings resolves typeParameters to ExactTypePattern(String) resolves Foo to RT(Foo) returns
ExactTypePattern(PFoo<String>; - parameterized)
Foo<Str*> where Foo exists and takes one bound Parser creates WildTypePattern namePatterns = {Foo}, typeParameters=WTP{Str*}
resolveBindings resolves typeParameters to WTP{Str*} resolves Foo to RT(Foo) returns WildTypePattern(name = Foo, typeParameters =
WTP{Str*} isGeneric=false)
Fo*<String> Parser creates WildTypePattern namePatterns = {Fo*}, typeParameters=WTP{String} resolveBindings resolves
typeParameters to ETP{String} returns WildTypePattern(name = Fo*, typeParameters = ETP{String} isGeneric=false)
Foo<?>
Foo<? extends Number>
Foo<? extends Number+>
Foo<? super Number>
-
Nested Class Summary
Nested classes/interfaces inherited from class org.aspectj.weaver.patterns.TypePattern
TypePattern.MatchKind -
Field Summary
FieldsFields inherited from class org.aspectj.weaver.patterns.TypePattern
AND, annotationPattern, ANY, ANY_KEY, ANY_WITH_ANNO, BINDING, DYNAMIC, ELLIPSIS, ELLIPSIS_KEY, EXACT, HAS_MEMBER, includeSubtypes, isVarArgs, NO, NO_KEY, NOT, OR, STATIC, TYPE_CATEGORY, typeParameters, WILDFields inherited from class org.aspectj.weaver.patterns.PatternNode
end, sourceContext, start -
Constructor Summary
ConstructorsConstructorDescriptionWildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim)WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos)WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg)WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams)WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams, TypePattern upperBound, TypePattern[] additionalInterfaceBounds, TypePattern lowerBound) -
Method Summary
Modifier and TypeMethodDescriptionaccept(PatternNodeVisitor visitor, Object data)protected booleancouldEverMatchSameTypesAs(TypePattern other)booleanintUsed in conjunction with checks on 'isStar()' to tell you if this pattern represents '*' or '*[]' which are different !booleaninthashCode()booleanisArray()booleanisStar()protected booleanmatchesExactly(ResolvedType type)protected booleanmatchesExactly(ResolvedType type, ResolvedType annotatedType)matchesInstanceof(ResolvedType type)booleanmaybeExtractName(String string)Method maybeExtractName.If this type pattern has no '*' or '..' in itIf this type pattern has no '.' or '*' in it, then return a simple string otherwise, this will return null;parameterizeWith(Map<String,UnresolvedType> typeVariableMap, World w)return a version of this type pattern in which all type variable references have been replaced by their corresponding entry in the map.static TypePatternread(VersionedDataInputStream s, ISourceContext context)static TypePatternreadTypePattern150(VersionedDataInputStream s, ISourceContext context)static TypePatternresolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)Need to determine if I'm really a pattern or a reference to a formal We may wish to further optimize the case of pattern vs.voidsetIsVarArgs(boolean isVarArgs)static char[][]splitNames(String s, boolean convertDollar)toString()voidMethods inherited from class org.aspectj.weaver.patterns.TypePattern
getAnnotationPattern, getExactType, getTypeParameters, isBangVoid, isEllipsis, isIncludeSubtypes, isStarAnnotation, isVarArgs, isVoid, matches, matchesStatically, matchesSubtypes, matchesSubtypes, notExactType, postRead, remapAdviceFormals, resolve, resolveExactType, setAnnotationTypePattern, setTypeParametersMethods inherited from class org.aspectj.weaver.patterns.PatternNode
copyLocationFrom, getEnd, getFileName, getSourceContext, getSourceLocation, getStart, readLocation, setLocation, traverse, writeLocation
-
Field Details
-
boundscheckingoff
public static boolean boundscheckingoff
-
-
Constructor Details
-
WildTypePattern
-
WildTypePattern
-
WildTypePattern
public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg) -
WildTypePattern
public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams, TypePattern upperBound, TypePattern[] additionalInterfaceBounds, TypePattern lowerBound) -
WildTypePattern
public WildTypePattern(List<NamePattern> names, boolean includeSubtypes, int dim, int endPos, boolean isVarArg, TypePatternList typeParams)
-
-
Method Details
-
getNamePatterns
-
getUpperBound
-
getLowerBound
-
getAdditionalIntefaceBounds
-
setIsVarArgs
public void setIsVarArgs(boolean isVarArgs)- Overrides:
setIsVarArgsin classTypePattern
-
couldEverMatchSameTypesAs
- Overrides:
couldEverMatchSameTypesAsin classTypePattern
-
splitNames
-
matchesExactly
- Specified by:
matchesExactlyin classTypePattern- See Also:
TypePattern.matchesExactly(ResolvedType)
-
matchesExactly
- Specified by:
matchesExactlyin classTypePattern
-
getDimensions
public int getDimensions()Used in conjunction with checks on 'isStar()' to tell you if this pattern represents '*' or '*[]' which are different ! -
isArray
public boolean isArray()- Overrides:
isArrayin classTypePattern
-
matchesInstanceof
- Specified by:
matchesInstanceofin classTypePattern- See Also:
TypePattern.matchesInstanceof(ResolvedType)
-
extractName
-
maybeExtractName
Method maybeExtractName.- Parameters:
string-- Returns:
- boolean
-
maybeGetSimpleName
If this type pattern has no '.' or '*' in it, then return a simple string otherwise, this will return null; -
maybeGetCleanName
If this type pattern has no '*' or '..' in it -
parameterizeWith
Description copied from class:TypePatternreturn a version of this type pattern in which all type variable references have been replaced by their corresponding entry in the map.- Specified by:
parameterizeWithin classTypePattern
-
resolveBindings
public TypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType)Need to determine if I'm really a pattern or a reference to a formal We may wish to further optimize the case of pattern vs. non-pattern We will be replaced by what we return- Overrides:
resolveBindingsin classTypePattern
-
isStar
public boolean isStar()- Overrides:
isStarin classTypePattern
-
toString
-
equals
-
hashCode
public int hashCode() -
write
- Specified by:
writein classPatternNode- Throws:
IOException
-
read
public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException- Throws:
IOException
-
readTypePattern150
public static TypePattern readTypePattern150(VersionedDataInputStream s, ISourceContext context) throws IOException- Throws:
IOException
-
readTypePatternOldStyle
public static TypePattern readTypePatternOldStyle(VersionedDataInputStream s, ISourceContext context) throws IOException- Throws:
IOException
-
accept
- Specified by:
acceptin classPatternNode
-
hasFailedResolution
public boolean hasFailedResolution()- Overrides:
hasFailedResolutionin classTypePattern
-