@Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; AnnotationRef that = (AnnotationRef) o; if (!classRef.equals(that.classRef)) return false; return true; }
private static boolean canBeExcluded(ClassRef candidate, Iterable<ClassRef> provided) { Set<ClassRef> allOther = new LinkedHashSet<ClassRef>(); for (ClassRef c : provided) { if (!c.equals(candidate)) { allOther.add(c); } } Set<ClassRef> allProvided = TypeDefUtils.extractInterfacesFromClassRefs(allOther); for (ClassRef type : TypeDefUtils.extractInterfacesFromClassRef(candidate)) { if (!allProvided.contains(type)) { return false; } } return true; }
private static boolean hasBuildableAnnotation(Method method) { for (AnnotationRef annotationRef : method.getAnnotations()) { if (annotationRef.getClassRef().equals(Constants.BUILDABLE_ANNOTATION.getClassRef())) { return true; } } return false; }
public boolean isAssignableFrom(TypeRef other) { if (this == other) { return true; } else if (other == null) { return false; } else if (other instanceof PrimitiveRef) { if (getDefinition() == null) { return false; } if (getDefinition() != null && !JAVA_LANG.equals(getDefinition().getPackageName())) { return false; } if (!getDefinition().getName().toUpperCase().startsWith(((PrimitiveRef) other).getName().toUpperCase())) { return false; } return true; } if (!(other instanceof ClassRef)) { return false; } if (this == other || this.equals(other)) { return true; } return definition.isAssignableFrom(((ClassRef) other).getDefinition()); }
private static Method superConstructorOf(Method constructor, TypeDef constructorType) { List<AnnotationRef> annotations = new ArrayList<AnnotationRef>(); for (AnnotationRef candidate : constructor.getAnnotations()) { if (!candidate.getClassRef().equals(BUILDABLE_ANNOTATION.getClassRef())) { annotations.add(candidate); } } return new MethodBuilder(constructor) .withAnnotations(annotations) .withReturnType(constructorType.toReference()) .withNewBlock() .addNewStringStatementStatement("super(" + StringUtils.join(constructor.getArguments(), new Function<Property, String>() { public String apply(Property item) { return item.getName(); } }, ", ") + ");") .endBlock() .build(); } }