/** * Determines if action input parameter is an array or collection. * * @return true if array or collection */ public boolean isArrayOrCollection() { if (arrayOrCollection == null) { arrayOrCollection = DataType.isArrayOrCollection(getParameterType()); } return arrayOrCollection; }
/** * Determines if action input parameter is an array or collection. * * @return true if array or collection */ public boolean isArrayOrCollection() { if (arrayOrCollection == null) { arrayOrCollection = DataType.isArrayOrCollection(getParameterType()); } return arrayOrCollection; }
private static List<String> addPropertyPaths(List<String> ret, String currentPath, PropertyDescriptor propertyDescriptor) { String propertyName = propertyDescriptor.getName(); if ("class".equals(propertyName)) { return Collections.emptyList(); } Class<?> propertyType = propertyDescriptor.getPropertyType(); if (DataType.isSingleValueType(propertyType)) { if (!currentPath.isEmpty()) { currentPath += "."; } ret.add(currentPath + propertyName); } else if (DataType.isArrayOrCollection(propertyType)) { LOG.warn((currentPath.isEmpty() ? currentPath : currentPath + ".") + propertyName + ": property paths for collections not supported yet"); // TODO support for collection properties } else { currentPath += propertyName; addClassPropertyPaths(ret, currentPath, propertyType); } return ret; }
private static List<String> addPropertyPaths(List<String> ret, String currentPath, PropertyDescriptor propertyDescriptor) { String propertyName = propertyDescriptor.getName(); if ("class".equals(propertyName)) { return Collections.emptyList(); } Class<?> propertyType = propertyDescriptor.getPropertyType(); if (DataType.isSingleValueType(propertyType)) { if (!currentPath.isEmpty()) { currentPath += "."; } ret.add(currentPath + propertyName); } else if (DataType.isArrayOrCollection(propertyType)) { LOG.warn((currentPath.isEmpty() ? currentPath : currentPath + ".") + propertyName + ": property paths for collections not supported yet"); // TODO support for collection properties } else { currentPath += propertyName; addClassPropertyPaths(ret, currentPath, propertyType); } return ret; }
@Test public void isArrayOrCollection() { assertTrue(DataType.isArrayOrCollection(String[].class)); assertTrue(DataType.isArrayOrCollection(List.class)); assertTrue(DataType.isArrayOrCollection(Set.class)); assertTrue(DataType.isArrayOrCollection(Collection.class)); assertFalse(DataType.isArrayOrCollection(Map.class)); assertFalse(DataType.isArrayOrCollection(Object.class)); }
!(DataType.isSingleValueType(parameterType) || DataType.isArrayOrCollection(parameterType))) { Input inputAnnotation = inputParam.getParameterAnnotation(Input.class);
!(DataType.isSingleValueType(parameterType) || DataType.isArrayOrCollection(parameterType))) { Input inputAnnotation = inputParam.getParameterAnnotation(Input.class);
private void addSirenFieldsForMethodParameter(List<SirenField> sirenFields, MethodParameter methodParameter, ActionInputParameter annotatedParameter, ActionDescriptor annotatedParameters, String parentParamName, String paramName, Class parameterType, Object propertyValue, Set<String> knownFields) { if (DataType.isSingleValueType(parameterType) || DataType.isArrayOrCollection(parameterType)) { if (annotatedParameter.isIncluded(paramName) && !knownFields.contains(parentParamName + paramName)) { ActionInputParameter constructorParamInputParameter = new SpringActionInputParameter(methodParameter, propertyValue); final Object[] possibleValues = annotatedParameter.getPossibleValues(methodParameter, annotatedParameters); // dot-separated property path as field name SirenField sirenField = createSirenField(parentParamName + paramName, propertyValue, constructorParamInputParameter, possibleValues); sirenFields.add(sirenField); } } else { Object callValueBean; if (propertyValue instanceof Resource) { callValueBean = ((Resource) propertyValue).getContent(); } else { callValueBean = propertyValue; } recurseBeanCreationParams(sirenFields, parameterType, annotatedParameters, annotatedParameter, callValueBean, paramName + ".", knownFields); } }
private static void addUberFieldsForMethodParameter(List<UberField> fields, MethodParameter methodParameter, ActionInputParameter annotatedParameter, ActionDescriptor annotatedParameters, String parentParamName, String paramName, Class parameterType, Object propertyValue, Set<String> knownFields) { if (DataType.isSingleValueType(parameterType) || DataType.isArrayOrCollection(parameterType)) { if (annotatedParameter.isIncluded(paramName) && !knownFields.contains(parentParamName + paramName)) { ActionInputParameter constructorParamInputParameter = new SpringActionInputParameter(methodParameter, propertyValue); final Object[] possibleValues = annotatedParameter.getPossibleValues(methodParameter, annotatedParameters); // dot-separated property path as field name UberField field = createUberField(parentParamName + paramName, propertyValue, constructorParamInputParameter, possibleValues); fields.add(field); } } else { Object callValueBean; if (propertyValue instanceof Resource) { callValueBean = ((Resource) propertyValue).getContent(); } else { callValueBean = propertyValue; } recurseBeanCreationParams(fields, parameterType, annotatedParameters, annotatedParameter, callValueBean, paramName + ".", knownFields); } }
private static void addUberFieldsForMethodParameter(List<UberField> fields, MethodParameter methodParameter, ActionInputParameter annotatedParameter, ActionDescriptor annotatedParameters, String parentParamName, String paramName, Class parameterType, Object propertyValue, Set<String> knownFields) { if (DataType.isSingleValueType(parameterType) || DataType.isArrayOrCollection(parameterType)) { if (annotatedParameter.isIncluded(paramName) && !knownFields.contains(parentParamName + paramName)) { ActionInputParameter constructorParamInputParameter = new SpringActionInputParameter(methodParameter, propertyValue); final Object[] possibleValues = annotatedParameter.getPossibleValues(methodParameter, annotatedParameters); // dot-separated property path as field name UberField field = createUberField(parentParamName + paramName, propertyValue, constructorParamInputParameter, possibleValues); fields.add(field); } } else { Object callValueBean; if (propertyValue instanceof Resource) { callValueBean = ((Resource) propertyValue).getContent(); } else { callValueBean = propertyValue; } recurseBeanCreationParams(fields, parameterType, annotatedParameters, annotatedParameter, callValueBean, paramName + ".", knownFields); } }
private void addSirenFieldsForMethodParameter(List<SirenField> sirenFields, MethodParameter methodParameter, ActionInputParameter annotatedParameter, ActionDescriptor annotatedParameters, String parentParamName, String paramName, Class parameterType, Object propertyValue, Set<String> knownFields) { if (DataType.isSingleValueType(parameterType) || DataType.isArrayOrCollection(parameterType)) { if (annotatedParameter.isIncluded(paramName) && !knownFields.contains(parentParamName + paramName)) { ActionInputParameter constructorParamInputParameter = new SpringActionInputParameter(methodParameter, propertyValue); final Object[] possibleValues = annotatedParameter.getPossibleValues(methodParameter, annotatedParameters); // dot-separated property path as field name SirenField sirenField = createSirenField(parentParamName + paramName, propertyValue, constructorParamInputParameter, possibleValues); sirenFields.add(sirenField); } } else { Object callValueBean; if (propertyValue instanceof Resource) { callValueBean = ((Resource) propertyValue).getContent(); } else { callValueBean = propertyValue; } recurseBeanCreationParams(sirenFields, parameterType, annotatedParameters, annotatedParameter, callValueBean, paramName + ".", knownFields); } }
constructorParamInputParameter, possibleValues); } else if (DataType.isArrayOrCollection(parameterType)) { Object[] callValues = actionInputParameter.getValues(); int items = callValues.length;
constructorParamInputParameter, possibleValues); } else if (DataType.isArrayOrCollection(parameterType)) { Object[] callValues = actionInputParameter.getValues(); int items = callValues.length;