@Override public List<Field> findAnnotatedFields(final Class<? extends Annotation> annotation) { return fieldCache.computeIfAbsent(annotation, a -> super.findAnnotatedFields(annotation)); }
private void validateOptionNames(final AnnotationFinder finder, final Set<String> errors) { errors.addAll(finder.findAnnotatedFields(Option.class).stream().filter(field -> { final String name = field.getAnnotation(Option.class).value(); return name.contains(".") || name.startsWith("$"); }).distinct().map(field -> { final String name = field.getAnnotation(Option.class).value(); return "Option name `" + name + "` is invalid, you can't start an option name with a '$' and it can't contain a '.'. " + "Please fix it on field `" + field.getDeclaringClass().getName() + "#" + field.getName() + "`"; }).sorted().collect(toSet())); }
private void validateDocumentation(final AnnotationFinder finder, final List<Class<?>> components, final Set<String> errors) { errors .addAll(components .stream() .filter(c -> !c.isAnnotationPresent(Documentation.class)) .map(c -> "No @Documentation on '" + c.getName() + "'") .sorted() .collect(toSet())); errors .addAll(finder .findAnnotatedFields(Option.class) .stream() .filter(field -> !field.isAnnotationPresent(Documentation.class) && !field.getType().isAnnotationPresent(Documentation.class)) .map(field -> "No @Documentation on '" + field + "'") .sorted() .collect(toSet())); }
.concat(finder.findAnnotatedFields(DefaultValue.class).stream(), finder.findAnnotatedConstructorParameters(DefaultValue.class).stream()) .map(d -> {
.findAnnotatedFields(Structure.class) .stream() .filter(f -> !ParameterizedType.class.isInstance(f.getGenericType())
.findAnnotatedFields(Option.class) .stream() .map(Field::getType) finder.findAnnotatedFields(Option.class).stream().distinct().filter(field -> { final ResourceBundle bundle = ofNullable(findResourceBundle(field.getDeclaringClass())) .orElseGet(() -> findResourceBundle(field.getType()));
.sorted() .collect(toSet())); final List<Field> updatableFields = finder.findAnnotatedFields(Updatable.class); errors .addAll(updatableFields .findAnnotatedFields(Proposable.class) .stream() .filter(f -> f.getType().isEnum()) .findAnnotatedFields(Proposable.class) .stream() .map(f -> f.getAnnotation(Proposable.class).value())