List of usage examples for org.springframework.core.convert Property getType
public Class<?> getType()
From source file:de.escalon.hypermedia.action.ActionInputParameter.java
public Object[] getPossibleValues(Property property, ActionDescriptor actionDescriptor) { // TODO remove code duplication of getPossibleValues try {/* w ww . ja v a 2s .c o m*/ Class<?> parameterType = property.getType(); 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(property, 1).getType())) { possibleValues = nested.getEnumConstants(); } else { Annotation[][] parameterAnnotations = property.getWriteMethod().getParameterAnnotations(); // setter has exactly one param Select select = getSelectAnnotationFromFirstParam(parameterAnnotations[0]); 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()) { ActionInputParameter parameterValue = actionDescriptor.getActionInputParameter(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); } }