public AnnotationRefFluentImpl(AnnotationRef instance){ this.withClassRef(instance.getClassRef()); this.withParameters(instance.getParameters()); this.withAttributes(instance.getAttributes()); }
public Set<ClassRef> getReferences() { Set<ClassRef> result = new HashSet<>(); result.add(classRef); for (Object o : parameters.values()) { if (o instanceof ClassRef) { result.add((ClassRef) o); } else if (o instanceof AnnotationRef) { result.addAll(((AnnotationRef) o).getReferences()); } else if (o instanceof Collection) { for (Object i : (Collection)o) { if (i instanceof ClassRef) { result.addAll(((ClassRef)i).getReferences()); } else if (i instanceof AnnotationRef) { result.addAll(((AnnotationRef)i).getReferences()); } } } } return result; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append(AT).append(classRef.toString()); if (parameters != null && parameters.size() > 0) { sb.append(OP); boolean first = true; for (Map.Entry<String, Object> entry : parameters.entrySet()) { Object value = entry.getValue(); if (first) { first = false; } else { sb.append(SPACE).append(COMA); } sb.append(entry.getKey()).append(SPACE).append(EQ).append(SPACE).append(toString(value)); } sb.append(CP); } return sb.toString(); } }
public static boolean isNestingFiltered(Property property, ClassRef classRef) { for (AnnotationRef ref : property.getAnnotations()) { if (ref.getClassRef().getFullyQualifiedName().equals(FilterDescendants.class.getName())) { Map<String, Object> parameters = ref.getParameters(); Object value = parameters == null ? null : parameters.get(VALUE); if (value instanceof String && property.getTypeRef() instanceof ClassRef) { Pattern p = Pattern.compile((String) value); if (p.matcher(classRef.getFullyQualifiedName()).matches()) { return false; } } return true; } } return false; }
private static boolean hasBuildableAnnotation(Method method) { for (AnnotationRef annotationRef : method.getAnnotations()) { if (annotationRef.getClassRef().equals(Constants.BUILDABLE_ANNOTATION.getClassRef())) { return true; } } return false; }
public Set<ClassRef> getReferences() { Set<ClassRef> refs = new LinkedHashSet<ClassRef>(); for (AnnotationRef annotationRef : annotations) { refs.addAll(annotationRef.getReferences()); } if (typeRef instanceof ClassRef) { ClassRef classRef = (ClassRef) typeRef; refs.addAll(classRef.getReferences()); } for (AnnotationRef a : getAnnotations()) { refs.addAll(a.getClassRef().getReferences()); } if (getAttributes().containsKey(ALSO_IMPORT)) { Object obj = getAttributes().get(ALSO_IMPORT); if (obj instanceof ClassRef) { refs.add((ClassRef) obj); } else if (obj instanceof Collection) { refs.addAll((Collection<? extends ClassRef>) obj); } } return refs; }
public static boolean isNestingIgnored(Property property) { for (AnnotationRef ref : property.getAnnotations()) { if (ref.getClassRef().getFullyQualifiedName().equals(IgnoreDescendants.class.getName())) { return true; } } return false; }
if (r.getClassRef().getFullyQualifiedName().equals(Buildable.class.getTypeName())) { if (!annotationRefs.contains(r)) { annotationRefs.add(r); if (r.getClassRef().getFullyQualifiedName().equals(Pojo.class.getTypeName())) { pojoRef = r; Map<String, Object> params = r.getParameters(); mutable = Boolean.parseBoolean(String.valueOf(r.getParameters().getOrDefault("mutable", false))); pojoName = String.valueOf(r.getParameters().getOrDefault("name", pojoName)); String prefix = String.valueOf(r.getParameters().getOrDefault("prefix", "")); String suffix = String.valueOf(r.getParameters().getOrDefault("suffix", "")); pojoName = StringUtils.toPojoName(item.getName(), prefix, suffix); } else if (params.containsKey("relativePath")) { String superClassName = TypeUtils.toClassName(r.getParameters().getOrDefault("superClass","")); if (!superClassName.isEmpty()) { superClassName = superClassName.replaceAll("\\.class$", ""); Arrays.asList(r.getParameters().getOrDefault("interfaces", new Object[]{})).stream() .map(String::valueOf) .map(s -> s.replaceAll("\\.class$", "")) relativePath = String.valueOf(r.getParameters().getOrDefault("relativePath", ".")); if (o instanceof AnnotationRef) { AnnotationRef r = (AnnotationRef) o;
refs.addAll(annotationRef.getReferences()); refs.addAll(a.getClassRef().getReferences());
public AnnotationRefBuilder(AnnotationRef instance, Boolean validationEnabled) { this.fluent = this; this.withClassRef(instance.getClassRef()); this.withParameters(instance.getParameters()); this.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }
private static boolean hasPojoAnnotation(TypeDef typeDef) { return typeDef.getAnnotations().stream() .filter(a -> a.getClassRef().getDefinition().getFullyQualifiedName().equals(Pojo.class.getTypeName())) .findAny().isPresent(); }
StringBuilder sb = new StringBuilder(); for (AnnotationRef annotationRef: annotations) { sb.append(annotationRef.toString()).append(SPACE);
refs.addAll(a.getReferences());
public AnnotationRefBuilder(AnnotationRefFluent<?> fluent, AnnotationRef instance, Boolean validationEnabled) { this.fluent = fluent; fluent.withClassRef(instance.getClassRef()); fluent.withParameters(instance.getParameters()); fluent.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }
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(); } }
sb.append(annotationRef.toString()).append(SPACE);
/** * Creates the JSON schema for the particular {@TypeDef}. * @param definition The definition. * @return The schema. */ public static JSONSchemaProps from(TypeDef definition) { JSONSchemaPropsBuilder builder = new JSONSchemaPropsBuilder(); builder.withType("object"); List<String> required = new ArrayList<>(); for (Property property : TypeUtils.allProperties(definition)) { JSONSchemaProps schema = from(property.getTypeRef()); if (property.getAnnotations() .stream() .anyMatch(a -> a.getClassRef().getFullyQualifiedName().equals("javax.validation.constraints.NotNull"))) { required.add(property.getName()); } if (schema != null) { builder.addToProperties(property.getName(), from(property.getTypeRef())); } } builder.withRequired(required); return builder.build(); }
List<AnnotationRef> annotations = new ArrayList<AnnotationRef>(); for (AnnotationRef candidate : sourceMethod.getAnnotations()) { if (!candidate.getClassRef().getFullyQualifiedName().startsWith("io.sundr")) { annotations.add(candidate);