* PARC initial implementation
* ******************************************************************/
-
package org.aspectj.weaver.patterns;
import java.io.DataOutputStream;
/**
* !TypePattern
*
- * <p>any binding to formals is explicitly forbidden for any composite, ! is
- * just the most obviously wrong case.
+ * <p>
+ * any binding to formals is explicitly forbidden for any composite, ! is just the most obviously wrong case.
*
* @author Erik Hilsdale
* @author Jim Hugunin
*/
public class NotTypePattern extends TypePattern {
private TypePattern negatedPattern;
-
+
public NotTypePattern(TypePattern pattern) {
- super(false,false); //??? we override all methods that care about includeSubtypes
+ super(false, false); // ??? we override all methods that care about includeSubtypes
this.negatedPattern = pattern;
setLocation(pattern.getSourceContext(), pattern.getStart(), pattern.getEnd());
}
- public TypePattern getNegatedPattern() {
- return negatedPattern;
- }
+ public TypePattern getNegatedPattern() {
+ return negatedPattern;
+ }
- /* (non-Javadoc)
- * @see org.aspectj.weaver.patterns.TypePattern#couldEverMatchSameTypesAs(org.aspectj.weaver.patterns.TypePattern)
- */
+ @Override
protected boolean couldEverMatchSameTypesAs(TypePattern other) {
return true;
}
-
+
+ @Override
public FuzzyBoolean matchesInstanceof(ResolvedType type) {
return negatedPattern.matchesInstanceof(type).not();
}
+ @Override
protected boolean matchesExactly(ResolvedType type) {
return (!negatedPattern.matchesExactly(type) && annotationPattern.matches(type).alwaysTrue());
}
-
+
+ @Override
protected boolean matchesExactly(ResolvedType type, ResolvedType annotatedType) {
- return (!negatedPattern.matchesExactly(type,annotatedType) && annotationPattern.matches(annotatedType).alwaysTrue());
+ return (!negatedPattern.matchesExactly(type, annotatedType) && annotationPattern.matches(annotatedType).alwaysTrue());
}
-
+
+ @Override
public boolean matchesStatically(ResolvedType type) {
return !negatedPattern.matchesStatically(type);
}
-
+
+ @Override
public void setAnnotationTypePattern(AnnotationTypePattern annPatt) {
super.setAnnotationTypePattern(annPatt);
}
-
+
+ @Override
public void setIsVarArgs(boolean isVarArgs) {
negatedPattern.setIsVarArgs(isVarArgs);
}
-
-
+
+ @Override
public void write(DataOutputStream s) throws IOException {
s.writeByte(TypePattern.NOT);
negatedPattern.write(s);
annotationPattern.write(s);
writeLocation(s);
}
-
+
public static TypePattern read(VersionedDataInputStream s, ISourceContext context) throws IOException {
TypePattern ret = new NotTypePattern(TypePattern.read(s, context));
- if (s.getMajorVersion()>=AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) {
- ret.annotationPattern = AnnotationTypePattern.read(s,context);
+ if (s.getMajorVersion() >= AjAttribute.WeaverVersionInfo.WEAVER_VERSION_MAJOR_AJ150) {
+ ret.annotationPattern = AnnotationTypePattern.read(s, context);
}
ret.readLocation(context, s);
return ret;
}
- public TypePattern resolveBindings(
- IScope scope,
- Bindings bindings,
- boolean allowBinding, boolean requireExactType)
- {
- if (requireExactType) return notExactType(scope);
+ @Override
+ public TypePattern resolveBindings(IScope scope, Bindings bindings, boolean allowBinding, boolean requireExactType) {
+ if (requireExactType) {
+ return notExactType(scope);
+ }
negatedPattern = negatedPattern.resolveBindings(scope, bindings, false, false);
return this;
}
-
- public TypePattern parameterizeWith(Map typeVariableMap,World w) {
- TypePattern newNegatedPattern = negatedPattern.parameterizeWith(typeVariableMap,w);
+
+ @Override
+ public TypePattern parameterizeWith(Map typeVariableMap, World w) {
+ TypePattern newNegatedPattern = negatedPattern.parameterizeWith(typeVariableMap, w);
NotTypePattern ret = new NotTypePattern(newNegatedPattern);
ret.copyLocationFrom(this);
return ret;
}
-
+
+ @Override
public String toString() {
StringBuffer buff = new StringBuffer();
if (annotationPattern != AnnotationTypePattern.ANY) {
}
return buff.toString();
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#equals(java.lang.Object)
*/
+ @Override
public boolean equals(Object obj) {
- if (! (obj instanceof NotTypePattern)) return false;
- return (negatedPattern.equals(((NotTypePattern)obj).negatedPattern));
+ if (!(obj instanceof NotTypePattern)) {
+ return false;
+ }
+ return (negatedPattern.equals(((NotTypePattern) obj).negatedPattern));
}
-
- /* (non-Javadoc)
+
+ /*
+ * (non-Javadoc)
+ *
* @see java.lang.Object#hashCode()
*/
+ @Override
public int hashCode() {
return 17 + 37 * negatedPattern.hashCode();
}
- public Object accept(PatternNodeVisitor visitor, Object data) {
- return visitor.visit(this, data);
- }
-
+ @Override
+ public Object accept(PatternNodeVisitor visitor, Object data) {
+ return visitor.visit(this, data);
+ }
+
+ @Override
public Object traverse(PatternNodeVisitor visitor, Object data) {
- Object ret = accept(visitor,data);
+ Object ret = accept(visitor, data);
negatedPattern.traverse(visitor, ret);
return ret;
}