public static boolean isNestingIgnored(Property property) { for (AnnotationRef ref : property.getAnnotations()) { if (ref.getClassRef().getFullyQualifiedName().equals(IgnoreDescendants.class.getName())) { return true; } } return false; }
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; }
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; }
/** * 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(); }
public PropertyBuilder(PropertyFluent<?> fluent, Property instance, Boolean validationEnabled) { this.fluent = fluent; fluent.withAnnotations(instance.getAnnotations()); fluent.withTypeRef(instance.getTypeRef()); fluent.withName(instance.getName()); fluent.withModifiers(instance.getModifiers()); fluent.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }
public PropertyBuilder(Property instance, Boolean validationEnabled) { this.fluent = this; this.withAnnotations(instance.getAnnotations()); this.withTypeRef(instance.getTypeRef()); this.withName(instance.getName()); this.withModifiers(instance.getModifiers()); this.withAttributes(instance.getAttributes()); this.validationEnabled = validationEnabled; }
public PropertyFluentImpl(Property instance){ this.withAnnotations(instance.getAnnotations()); this.withTypeRef(instance.getTypeRef()); this.withName(instance.getName()); this.withModifiers(instance.getModifiers()); this.withAttributes(instance.getAttributes()); }