List of usage examples for org.springframework.core.convert Property Property
public Property(Class<?> objectType, @Nullable Method readMethod, @Nullable Method writeMethod,
@Nullable String name)
From source file:de.escalon.hypermedia.spring.de.escalon.hypermedia.spring.jackson.LinkListSerializer.java
private void recurseSupportedProperties(JsonGenerator jgen, String currentVocab, Class<?> beanType, ActionDescriptor actionDescriptor, ActionInputParameter actionInputParameter, Object currentCallValue) throws IntrospectionException, IOException { // TODO support Option provider by other method args? final BeanInfo beanInfo = Introspector.getBeanInfo(beanType); final PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); // TODO collection and map for (PropertyDescriptor propertyDescriptor : propertyDescriptors) { final Method writeMethod = propertyDescriptor.getWriteMethod(); if (writeMethod == null) { continue; }/*from w ww . j a v a2 s . c o m*/ final Class<?> propertyType = propertyDescriptor.getPropertyType(); // TODO: the property name must be a valid URI - need to check context for terms? String propertyName = getWritableExposedPropertyOrPropertyName(propertyDescriptor); if (DataType.isScalar(propertyType)) { final Property property = new Property(beanType, propertyDescriptor.getReadMethod(), propertyDescriptor.getWriteMethod(), propertyDescriptor.getName()); Object propertyValue = getPropertyValue(currentCallValue, propertyDescriptor); ActionInputParameter propertySetterInputParameter = new ActionInputParameter( new MethodParameter(propertyDescriptor.getWriteMethod(), 0), propertyValue); final Object[] possiblePropertyValues = actionInputParameter.getPossibleValues(property, actionDescriptor); writeSupportedProperty(jgen, currentVocab, propertySetterInputParameter, propertyName, property, possiblePropertyValues); } else { jgen.writeStartObject(); jgen.writeStringField("hydra:property", propertyName); // TODO: is the property required -> for bean props we need the Access annotation to express that jgen.writeObjectFieldStart(getPropertyOrClassNameInVocab(currentVocab, "rangeIncludes", JacksonHydraSerializer.HTTP_SCHEMA_ORG, "schema:")); Expose expose = AnnotationUtils.getAnnotation(propertyType, Expose.class); String subClass; if (expose != null) { subClass = expose.value(); } else { subClass = propertyType.getSimpleName(); } jgen.writeStringField(getPropertyOrClassNameInVocab(currentVocab, "subClassOf", "http://www.w3.org/2000/01/rdf-schema#", "rdfs:"), subClass); jgen.writeArrayFieldStart("hydra:supportedProperty"); Object propertyValue = getPropertyValue(currentCallValue, propertyDescriptor); recurseSupportedProperties(jgen, currentVocab, propertyType, actionDescriptor, actionInputParameter, propertyValue); jgen.writeEndArray(); jgen.writeEndObject(); jgen.writeEndObject(); } } }
From source file:net.yasion.common.core.bean.wrapper.impl.ExtendedBeanWrapperImpl.java
private Property property(PropertyDescriptor pd) { GenericTypeAwarePropertyDescriptor typeAware = (GenericTypeAwarePropertyDescriptor) pd; return new Property(typeAware.getBeanClass(), typeAware.getReadMethod(), typeAware.getWriteMethod(), typeAware.getName());/*w w w . ja v a2s . com*/ }