return signature.length() > 0 && signature.charAt(0) == '[';
}
+ public final int getDimensions() {
+ return signature.replaceAll("^(\\[*).*", "$1").length();
+ }
+
/**
* Equality is checked based on the underlying signature.
*/
if (!(other instanceof UnresolvedType)) {
return false;
}
- return signature.equals(((UnresolvedType) other).signature);
+ final UnresolvedType unresolvedOther = (UnresolvedType) other;
+ return signature.equals(unresolvedOther.signature) && getDimensions() == unresolvedOther.getDimensions();
}
/**
*/
@Override
public int hashCode() {
- return signature.hashCode();
+ int result = 17;
+ result = 37 * result + signature.hashCode();
+ result = 37 * result + getDimensions();
+ return result;
}
protected UnresolvedType(String signature) {
return type.isArray();
}
+ public int getDimensions() {
+ return type.getDimensions();
+ }
+
/*
* (non-Javadoc)
*
@Override
protected boolean matchesExactly(ResolvedType matchType) {
+ if (!matchesArray(matchType)) {
+ return false;
+ }
boolean typeMatch = this.type.equals(matchType);
if (!typeMatch && (matchType.isParameterizedType() || matchType.isGenericType())) {
typeMatch = this.type.equals(matchType.getRawType());
@Override
protected boolean matchesExactly(ResolvedType matchType, ResolvedType annotatedType) {
+ if (!matchesArray(matchType)) {
+ return false;
+ }
boolean typeMatch = this.type.equals(matchType);
if (!typeMatch && (matchType.isParameterizedType() || matchType.isGenericType())) {
typeMatch = this.type.equals(matchType.getRawType());
* Matches on name, declaring type, return type, parameter types, throws types
*/
private FuzzyBoolean matchesExactlyMethod(JoinPointSignature aMethod, World world, boolean subjectMatch) {
+ if (aMethod.getReturnType().getDimensions() != returnType.getDimensions()) {
+ return FuzzyBoolean.NO;
+ }
if (parametersCannotMatch(aMethod)) {
// System.err.println("Parameter types pattern " + parameterTypes + " pcount: " + aMethod.getParameterTypes().length);
return FuzzyBoolean.NO;
return false;
}
+ public int getDimensions() {
+ return 0;
+ }
+
protected TypePattern(boolean includeSubtypes) {
this(includeSubtypes, false);
}
protected abstract boolean matchesExactly(ResolvedType type, ResolvedType annotatedType);
+ protected boolean matchesArray(ResolvedType type) {
+ return type.getDimensions() == getDimensions();
+ }
+
protected boolean matchesSubtypes(ResolvedType type) {
// System.out.println("matching: " + this + " to " + type);
if (matchesExactly(type)) {
}
}
-
-
-
annotationPattern.resolve(type.getWorld());
return matchesExactlyByName(targetTypeName, type.isAnonymous(), type.isNested()) && matchesParameters(type, STATIC)
+ && matchesArray(type)
&& matchesBounds(type, STATIC)
&& annotationPattern.matches(annotatedType, type.temporaryAnnotationTypes).alwaysTrue();
}
}
}
- return innerMatchesExactly(targetTypeName, isAnonymous, isNested);
+ return innerMatchesExactly(targetTypeName.substring(0, targetTypeName.length() - dim * 2), isAnonymous, isNested);
}
private int lastIndexOfDotOrDollar(String string) {