private void addFacetsForArray(FieldSpec.Builder typeSpec, ArrayTypeDeclaration typeDeclaration) { AnnotationSpec.Builder minMax = null; if (typeDeclaration.minItems() != null) { minMax = AnnotationSpec.builder(Size.class).addMember("min", "$L", typeDeclaration.minItems()); } if (typeDeclaration.maxItems() != null) { if (minMax == null) { minMax = AnnotationSpec.builder(Size.class).addMember("max", "$L", typeDeclaration.maxItems()); } else { minMax.addMember("max", "$L", typeDeclaration.maxItems()); } } if (minMax != null) { typeSpec.addAnnotation(minMax.build()); } }
private void addFacetsForArray(FieldSpec.Builder fieldSpec, ArrayTypeDeclaration typeDeclaration) { if ( isFieldFromBuiltType(typeDeclaration.items()) ) { fieldSpec.addAnnotation(Valid.class); } AnnotationSpec.Builder minMax = null; if (typeDeclaration.minItems() != null) { minMax = AnnotationSpec.builder(Size.class).addMember("min", "$L", typeDeclaration.minItems()); } if (typeDeclaration.maxItems() != null) { if (minMax == null) { minMax = AnnotationSpec.builder(Size.class).addMember("max", "$L", typeDeclaration.maxItems()); } else { minMax.addMember("max", "$L", typeDeclaration.maxItems()); } } if (minMax != null) { fieldSpec.addAnnotation(minMax.build()); } }
validations.withLenghts(arrayType.minItems(), arrayType.maxItems());