/** * Converts a set of constraints to human-readable values. * Does not guarantee the order of the returned constraints. * * This method calls {@code displayableConstraint} under the hood. * * @param constraints the set of constraint descriptors. * @return a list of pairs of tuples assembled from displayableConstraint. */ public static List<Tuple<String,List<Object>>> displayableConstraint(Set<ConstraintDescriptor<?>> constraints) { return constraints.parallelStream().filter(c -> c.getAnnotation().annotationType().isAnnotationPresent(Display.class)).map(c -> displayableConstraint(c)).collect(Collectors.toList()); }
/** * Converts a set of constraints to human-readable values. * Does not guarantee the order of the returned constraints. * * This method calls {@code displayableConstraint} under the hood. * * @param constraints the set of constraint descriptors. * @return a list of pairs of tuples assembled from displayableConstraint. */ public static List<Tuple<String,List<Object>>> displayableConstraint(Set<ConstraintDescriptor<?>> constraints) { return constraints.parallelStream().filter(c -> c.getAnnotation().annotationType().isAnnotationPresent(Display.class)).map(c -> displayableConstraint(c)).collect(Collectors.toList()); }
/** * Converts a set of constraints to human-readable values. * Does not guarantee the order of the returned constraints. * * This method calls {@code displayableConstraint} under the hood. * * @param constraints the set of constraint descriptors. * @return a list of pairs of tuples assembled from displayableConstraint. */ public static List<Tuple<String,List<Object>>> displayableConstraint(Set<ConstraintDescriptor<?>> constraints) { return constraints.parallelStream().filter(c -> c.getAnnotation().annotationType().isAnnotationPresent(Display.class)).map(c -> displayableConstraint(c)).collect(Collectors.toList()); }
/** * Converts a set of constraints to human-readable values in guaranteed order. * Only constraints that have an annotation that intersect with the {@code orderedAnnotations} parameter will be considered. * The order of the returned constraints corresponds to the order of the {@code orderedAnnotations parameter}. * @param constraints the set of constraint descriptors. * @param orderedAnnotations the array of annotations * @return a list of tuples showing readable constraints. */ public static List<Tuple<String,List<Object>>> displayableConstraint(Set<ConstraintDescriptor<?>> constraints, Annotation[] orderedAnnotations) { final List<Annotation> constraintAnnot = constraints.stream(). map(c -> c.getAnnotation()). collect(Collectors.<Annotation>toList()); return Stream .of(orderedAnnotations) .filter(constraintAnnot::contains) // only use annotations for which we actually have a constraint .filter(a -> a.annotationType().isAnnotationPresent(Display.class)) .map(a -> displayableConstraint( constraints.parallelStream() .filter(c -> c.getAnnotation().equals(a)) .findFirst() .get() ) ).collect(Collectors.toList()); }
/** * Converts a set of constraints to human-readable values in guaranteed order. * Only constraints that have an annotation that intersect with the {@code orderedAnnotations} parameter will be considered. * The order of the returned constraints corresponds to the order of the {@code orderedAnnotations parameter}. * @param constraints the set of constraint descriptors. * @param orderedAnnotations the array of annotations * @return a list of tuples showing readable constraints. */ public static List<Tuple<String,List<Object>>> displayableConstraint(Set<ConstraintDescriptor<?>> constraints, Annotation[] orderedAnnotations) { final List<Annotation> constraintAnnot = constraints.stream(). map(c -> c.getAnnotation()). collect(Collectors.<Annotation>toList()); return Stream .of(orderedAnnotations) .filter(constraintAnnot::contains) // only use annotations for which we actually have a constraint .filter(a -> a.annotationType().isAnnotationPresent(Display.class)) .map(a -> displayableConstraint( constraints.parallelStream() .filter(c -> c.getAnnotation().equals(a)) .findFirst() .get() ) ).collect(Collectors.toList()); }
/** * Converts a set of constraints to human-readable values in guaranteed order. * Only constraints that have an annotation that intersect with the {@code orderedAnnotations} parameter will be considered. * The order of the returned constraints corresponds to the order of the {@code orderedAnnotations parameter}. * @param constraints the set of constraint descriptors. * @param orderedAnnotations the array of annotations * @return a list of tuples showing readable constraints. */ public static List<Tuple<String,List<Object>>> displayableConstraint(Set<ConstraintDescriptor<?>> constraints, Annotation[] orderedAnnotations) { final List<Annotation> constraintAnnot = constraints.stream(). map(c -> c.getAnnotation()). collect(Collectors.<Annotation>toList()); return Stream .of(orderedAnnotations) .filter(constraintAnnot::contains) // only use annotations for which we actually have a constraint .filter(a -> a.annotationType().isAnnotationPresent(Display.class)) .map(a -> displayableConstraint( constraints.parallelStream() .filter(c -> c.getAnnotation().equals(a)) .findFirst() .get() ) ).collect(Collectors.toList()); }
PropertyDescriptor property = beanDescriptor.getConstraintsForProperty(leafKey); if(property != null) { constraints = Constraints.displayableConstraint(property.getConstraintDescriptors());
PropertyDescriptor property = beanDescriptor.getConstraintsForProperty(leafKey); if(property != null) { constraints = Constraints.displayableConstraint(property.getConstraintDescriptors());
break; constraints = Constraints.displayableConstraint( property.findConstraints().unorderedAndMatchingGroups(groups != null ? groups : new Class[]{Default.class}).getConstraintDescriptors(), orderedAnnotations
break; constraints = Constraints.displayableConstraint( property.findConstraints().unorderedAndMatchingGroups(groups != null ? groups : new Class[]{Default.class}).getConstraintDescriptors(), orderedAnnotations
break; constraints = Constraints.displayableConstraint( property.findConstraints().unorderedAndMatchingGroups(groups != null ? groups : new Class[]{Default.class}).getConstraintDescriptors(), orderedAnnotations