private static Object getContentAsScalarValue(Object content) { final Object value; if (content == null) { value = UberNode.NULL_VALUE; } else if (DataType.isSingleValueType(content.getClass())) { value = content.toString(); } else { value = null; } return value; }
private static Object getContentAsScalarValue(Object content) { final Object value; if (content == null) { value = ResourceTraversal.NULL_VALUE; } else if (DataType.isSingleValueType(content.getClass())) { value = content.toString(); } else { value = null; } return value; } }
private static Object getContentAsScalarValue(Object content) { final Object value; if (content == null) { value = ResourceTraversal.NULL_VALUE; } else if (DataType.isSingleValueType(content.getClass())) { value = content.toString(); } else { value = null; } return value; } }
private static Object getContentAsScalarValue(Object content) { final Object value; if (content == null) { value = UberNode.NULL_VALUE; } else if (DataType.isSingleValueType(content.getClass())) { value = content.toString(); } else { value = null; } return value; }
private Object getContentAsScalarValue(Object content) { Object value = null; if (content == null) { value = NULL_VALUE; } else if (DataType.isSingleValueType(content.getClass())) { value = DataType.asScalarValue(content); } return value; }
private Object getContentAsScalarValue(Object content) { Object value = null; if (content == null) { value = NULL_VALUE; } else if (DataType.isSingleValueType(content.getClass())) { value = DataType.asScalarValue(content); } return value; }
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; }
Collection<?> collection = (Collection<?>) content; for (Object item : collection) { if (DataType.isSingleValueType(item.getClass())) { Object listObject = propertiesNode.get(name); if (listObject == null) {
Collection<?> collection = (Collection<?>) content; for (Object item : collection) { if (DataType.isSingleValueType(item.getClass())) { Object listObject = propertiesNode.get(name); if (listObject == null) {
@Test public void testIsSingleValueType() throws Exception { Assert.assertTrue(DataType.isSingleValueType(int.class)); Assert.assertTrue(DataType.isSingleValueType(Integer.class)); Assert.assertTrue(DataType.isSingleValueType(BigInteger.class)); Assert.assertTrue(DataType.isSingleValueType(BigDecimal.class)); Assert.assertTrue(DataType.isSingleValueType(boolean.class)); Assert.assertTrue(DataType.isSingleValueType(Boolean.class)); Assert.assertTrue(DataType.isSingleValueType(EventStatusType.class)); Assert.assertTrue(DataType.isSingleValueType(Date.class)); Assert.assertTrue(DataType.isSingleValueType(Calendar.class)); Assert.assertTrue(DataType.isSingleValueType(Currency.class)); Assert.assertFalse(DataType.isSingleValueType(Object.class)); }
private void writeObject(XhtmlWriter writer, Object object) throws IOException, IllegalAccessException, InvocationTargetException { if (!DataType.isSingleValueType(object.getClass())) { writer.beginDl(); if (!DataType.isSingleValueType(object.getClass())) { writer.endDl();
private void writeObject(XhtmlWriter writer, Object object) throws IOException, IllegalAccessException, InvocationTargetException { if (!DataType.isSingleValueType(object.getClass())) { writer.beginDl(); if (!DataType.isSingleValueType(object.getClass())) { writer.endDl();
@Test public void testIsSingleValueTypeInt() throws Exception { Assert.assertTrue(DataType.isSingleValueType(int.class)); }
private void writeObjectAttributeRecursively(XhtmlWriter writer, String name, Object content, String documentationUrl) throws IOException { Object value = getContentAsScalarValue(content); if (!contentIsEmpty(content)) { writeDtWithDoc(writer, name, documentationUrl); } if (value != null) { if (value != NULL_VALUE) { writeDdForScalarValue(writer, value); } } else if (DataType.isSingleValueType(content.getClass())) { writeDdForScalarValue(writer, content.toString()); } else { writer.beginDd(); writeNewResource(writer, content); writer.endDd(); } }
private void writeObjectAttributeRecursively(XhtmlWriter writer, String name, Object content, String documentationUrl) throws IOException { Object value = getContentAsScalarValue(content); if (!contentIsEmpty(content)) { writeDtWithDoc(writer, name, documentationUrl); } if (value != null) { if (value != NULL_VALUE) { writeDdForScalarValue(writer, value); } } else if (DataType.isSingleValueType(content.getClass())) { writeDdForScalarValue(writer, content.toString()); } else { writer.beginDd(); writeNewResource(writer, content); writer.endDd(); } }
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); } }