From: aclement Date: Sat, 7 Nov 2009 00:33:25 +0000 (+0000) Subject: generics X-Git-Tag: V1_6_7~140 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=ef8f7bc3649cdc055acb19be748257fb51efb3fc;p=aspectj.git generics --- diff --git a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotTypePattern.java b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotTypePattern.java index 5ade60e45..01adce402 100644 --- a/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotTypePattern.java +++ b/org.aspectj.matcher/src/org/aspectj/weaver/patterns/NotTypePattern.java @@ -10,7 +10,6 @@ * PARC initial implementation * ******************************************************************/ - package org.aspectj.weaver.patterns; import java.io.DataOutputStream; @@ -27,90 +26,95 @@ import org.aspectj.weaver.World; /** * !TypePattern * - *

any binding to formals is explicitly forbidden for any composite, ! is - * just the most obviously wrong case. + *

+ * 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) { @@ -125,28 +129,38 @@ public class NotTypePattern extends TypePattern { } 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; }