private static boolean isMatch(List<OJPathName> pathnames, List<OJPathName> paramTypes) { if (paramTypes.size() == pathnames.size()) { for (int i = 0; i < paramTypes.size(); i++) { if (!paramTypes.get(i).equals(pathnames.get(i))) { return false; } } return true; } return false; }
public boolean paramsEquals(List<OJPathName> oParamTypes){ List<OJPathName> paramTypes = getParamTypes(); boolean b = true; if(oParamTypes.size() == paramTypes.size()){ for(int i = 0;i < paramTypes.size();i++){ if(!paramTypes.get(i).equals(oParamTypes.get(i))){ b = false; break; } } }else{ b = false; } return b; } }
/** * Implements ->forAll( i : Integer | * self.parameters->at(i).type.equals(types->at(i)) ) * * @param name * @param types */ private boolean forAll2(String name, List<OJPathName> types) { Iterator it = collectionLiteral1(name, types).iterator(); while (it.hasNext()) { Integer i = (Integer) it.next(); if (!(this.getParameters().size() > i.intValue() - 1 ? ((OJParameter) this.getParameters().get(i.intValue() - 1)) : null).getType().equals( (types.size() > i.intValue() - 1 ? ((OJPathName) types.get(i.intValue() - 1)) : null))) { return false; } } return true; }
public static OJAnnotationValue getAnnotation(OJAnnotatedElement target, OJPathName path) { for (OJAnnotationValue v:target.getAnnotations()) { if (v.getType().equals(path)) { return v; } } return null; } }
public boolean isEqual(String name,List /* (OJPathName) */types){ boolean result = false; if(this.getName().equals(name)){ List<OJParameter> myPars = this.getParameters(); if((myPars.size() == 0) && (types.size() == 0)){ result = true; }else{ if(myPars.size() == types.size()){ Iterator parsIt = myPars.iterator(); Iterator typesIt = types.iterator(); boolean loopResult = true; while(parsIt.hasNext()){ OJParameter par = (OJParameter) parsIt.next(); OJPathName type = (OJPathName) typesIt.next(); if(!(par.getType().equals(type))){ loopResult = false; } } result = loopResult; } } } return result; } public List<OJPathName> getParamTypes(){
/** * Adds an annotation to the target element, but only if an annotation value of this type has not been associated * with the target yet. Returns true if the annotation value was added, false if an exeisting value was found for * that annotation * * @param value * @param target * @return */ public static boolean maybeAddAnnotation(OJAnnotationValue value, OJAnnotatedElement target) { Collection<OJAnnotationValue> sourceSet = target.getAnnotations(); for (Iterator<OJAnnotationValue> iter = sourceSet.iterator(); iter.hasNext();) { if (value.getType().equals(iter.next().getType())) { return false; } } sourceSet.add(value); return true; } public static OJAnnotationValue getAnnotation(OJAnnotatedElement target, OJPathName path) {
private String imports() { StringBuilder sb = new StringBuilder(); for (OJPathName path : getImports()) { if (getMyPackage().getPathName().equals(path.getHead())) { // already visible } else { sb.append("import " + path.toString() + ";\n"); } } return sb.toString(); } private Collection<OJPathName> getImports() {
/** * @return */ @SuppressWarnings("unchecked") protected StringBuilder imports() { // sort the imports by alphabeth Set myImports = new TreeSet(new OJPathNameComparator()); myImports.addAll(this.getImports()); // StringBuilder result = new StringBuilder(); Iterator it = myImports.iterator(); String prevPackageName = ""; while (it.hasNext()) { OJPathName path = (OJPathName) it.next(); if (!this.isInnerClass && this.getMyPackage().getPathName().equals(path.getHead())) { // do nothing, imported element is in same package } else { if (!path.getFirst().equals(prevPackageName)) { result.append("\n"); } result.append("import " + path.toString() + ";\n"); prevPackageName = path.getFirst(); } } return result; }
} else if (path.getHead().equals(new OJPathName("java.lang"))) {