@Test void builtInSuggestionCustom() { assertEquals(singletonMap("tcomp::action::built_in_suggestable", "alternate"), new ActionParameterEnricher() .onParameterAnnotation("testParam", String.class, new BuiltInSuggestable() { @Override public Name value() { return Name.CUSTOM; } @Override public String name() { return "alternate"; } @Override public Class<? extends Annotation> annotationType() { return BuiltInSuggestable.class; } })); }
@Override public Map<String, String> onParameterAnnotation(final String parameterName, final Type parameterType, final Annotation annotation) { final Class<? extends Annotation> annotationType = annotation.annotationType(); final ActionRef ref = annotationType.getAnnotation(ActionRef.class); if (ref == null) { return emptyMap(); } final Class<?> actionType = ref.value(); if (actionType == Object.class) { return singletonMap( META_PREFIX + clientActionsMapping.computeIfAbsent(annotationType.getSimpleName(), this::toSnakeCase), getClientActionName(annotation)); } final String type = actionType.getAnnotation(ActionType.class).value(); return new HashMap<String, String>() { { put(META_PREFIX + type, getValueString(ref.ref(), annotation)); ofNullable(getParametersString(annotation)).ifPresent(v -> put(META_PREFIX + type + "::parameters", v)); Stream .of(annotationType.getMethods()) .filter(it -> annotationType == it.getDeclaringClass() && Stream.of("parameters", "value").noneMatch(v -> it.getName().equalsIgnoreCase(v))) .forEach(m -> put(META_PREFIX + type + "::" + m.getName(), getString(m, annotation))); } }; }
ActionParameterEnricher extends BaseParameterEnricher { @Override public Map<String, String> onParameterAnnotation(final String parameterName, final Type parameterType, final Annotation annotation) { final Class<? extends Annotation> annotationType = annotation.annotationType(); final ActionRef ref = annotationType.getAnnotation(ActionRef.class); if (ref == null) { return emptyMap(); } final Class<?> actionType = ref.value(); if (actionType == Object.class) { return singletonMap( META_PREFIX + clientActionsMapping.computeIfAbsent(annotationType.getSimpleName(), this::toSnakeCase), getClientActionName(annotation)); } final String type = actionType.getAnnotation(ActionType.class).value(); return new HashMap<String, String>() { { put(META_PREFIX + type, getValueString(ref.ref(), annotation)); ofNullable(getParametersString(annotation)).ifPresent(v -> put(META_PREFIX + type + "::parameters", v)); Stream .of(annotationType.getMethods()) .filter(it -> annotationType == it.getDeclaringClass() && Stream.of("parameters", "value").noneMatch(v -> it.getName().equalsIgnoreCase(v))) .forEach(m -> put(META_PREFIX + type + "::" + m.getName(), getString(m, annotation))); } }; } }
ActionParameterEnricher extends BaseParameterEnricher { @Override public Map<String, String> onParameterAnnotation(final String parameterName, final Type parameterType, final Annotation annotation) { final Class<? extends Annotation> annotationType = annotation.annotationType(); final ActionRef ref = annotationType.getAnnotation(ActionRef.class); if (ref == null) { return emptyMap(); } final Class<?> actionType = ref.value(); if (actionType == Object.class) { return singletonMap( META_PREFIX + clientActionsMapping.computeIfAbsent(annotationType.getSimpleName(), this::toSnakeCase), getClientActionName(annotation)); } final String type = actionType.getAnnotation(ActionType.class).value(); return new HashMap<String, String>() { { put(META_PREFIX + type, getValueString(ref.ref(), annotation)); ofNullable(getParametersString(annotation)).ifPresent(v -> put(META_PREFIX + type + "::parameters", v)); Stream .of(annotationType.getMethods()) .filter(it -> annotationType == it.getDeclaringClass() && Stream.of("parameters", "value").noneMatch(v -> it.getName().equalsIgnoreCase(v))) .forEach(m -> put(META_PREFIX + type + "::" + m.getName(), getString(m, annotation))); } }; }  }
ActionParameterEnricher extends BaseParameterEnricher { @Override public Map<String, String> onParameterAnnotation(final String parameterName, final Type parameterType, final Annotation annotation) { final Class<? extends Annotation> annotationType = annotation.annotationType(); final ActionRef ref = annotationType.getAnnotation(ActionRef.class); if (ref == null) { return emptyMap(); } final Class<?> actionType = ref.value(); if (actionType == Object.class) { return singletonMap( META_PREFIX + clientActionsMapping.computeIfAbsent(annotationType.getSimpleName(), this::toSnakeCase), getClientActionName(annotation)); } final String type = actionType.getAnnotation(ActionType.class).value(); return new HashMap<String, String>() { { put(META_PREFIX + type, getValueString(ref.ref(), annotation)); ofNullable(getParametersString(annotation)).ifPresent(v -> put(META_PREFIX + type + "::parameters", v)); Stream .of(annotationType.getMethods()) .filter(it -> annotationType == it.getDeclaringClass() && Stream.of("parameters", "value").noneMatch(v -> it.getName().equalsIgnoreCase(v))) .forEach(m -> put(META_PREFIX + type + "::" + m.getName(), getString(m, annotation))); } }; }  @Override Map<String, String> onParameterAnnotation(final String parameterName, final Type parameterType,
            final Annotation annotation); }
ActionParameterEnricher extends BaseParameterEnricher { @Override public Map<String, String> onParameterAnnotation(final String parameterName, final Type parameterType, final Annotation annotation) { final Class<? extends Annotation> annotationType = annotation.annotationType(); final ActionRef ref = annotationType.getAnnotation(ActionRef.class); if (ref == null) { return emptyMap(); } final Class<?> actionType = ref.value(); if (actionType == Object.class) { return singletonMap( META_PREFIX + clientActionsMapping.computeIfAbsent(annotationType.getSimpleName(), this::toSnakeCase), getClientActionName(annotation)); } final String type = actionType.getAnnotation(ActionType.class).value(); return new HashMap<String, String>() { { put(META_PREFIX + type, getValueString(ref.ref(), annotation)); ofNullable(getParametersString(annotation)).ifPresent(v -> put(META_PREFIX + type + "::parameters", v)); Stream .of(annotationType.getMethods()) .filter(it -> annotationType == it.getDeclaringClass() && Stream.of("parameters", "value").noneMatch(v -> it.getName().equalsIgnoreCase(v))) .forEach(m -> put(META_PREFIX + type + "::" + m.getName(), getString(m, annotation))); } }; }  @Override Map<String, String> onParameterAnnotation(final String parameterName, final Type parameterType,
            final Annotation annotation); static final String META_PREFIX; }