/** * Gets exposed property or parameter name. * * @param inputParameter for exposure * @return property name */ private String getExposedPropertyOrParamName(AnnotatedParameter inputParameter) { final Expose expose = inputParameter.getAnnotation(Expose.class); String property; if (expose != null) { property = expose.value(); } else { property = inputParameter.getParameterName(); } return property; }
@Override public String getDocumentationUrl(AnnotatedParameter parameter, Object content) { final Expose expose = parameter.getAnnotation(Expose.class); String ret; if (content == null) { Class<?> clazz = parameter.getDeclaringClass(); ret = getExposedUrl( parameter.getParameterName(), vocabFromClass(clazz), termsFromClazz(clazz), expose); } else { ret = getExposedUrl( parameter.getParameterName(), vocabFromBean(content), termsFromBean(content), expose); } return ret; }
private Object[] getPossibleValues( MethodParameter methodParameter, AnnotatedParameters actionDescriptor) { try { Class<?> parameterType = methodParameter.getNestedParameterType(); Object[] possibleValues; Class<?> nested; if (Enum[].class.isAssignableFrom(parameterType)) { possibleValues = parameterType.getComponentType().getEnumConstants(); } else if (Enum.class.isAssignableFrom(parameterType)) { possibleValues = parameterType.getEnumConstants(); } else if (Collection.class.isAssignableFrom(parameterType) && Enum.class.isAssignableFrom( nested = TypeDescriptor.nested(methodParameter, 1).getType())) { possibleValues = nested.getEnumConstants(); } else { Select select = methodParameter.getParameterAnnotation(Select.class); if (select != null) { Class<? extends Options> optionsClass = select.options(); Options options = optionsClass.newInstance(); // collect call values to pass to options.get List<Object> from = new ArrayList<Object>(); for (String paramName : select.args()) { AnnotatedParameter parameterValue = actionDescriptor.getAnnotatedParameter(paramName); if (parameterValue != null) { from.add(parameterValue.getCallValue()); } } Object[] args = from.toArray(); possibleValues = options.get(select.value(), args); } else { possibleValues = new Object[0]; } } return possibleValues; } catch (Exception e) { throw new RuntimeException(e); } }