/**
* Answers the structure type of a property, given an instance and the property name, if it exists. Throws an exception otherwise The structure type is not the same that the property type. According to SLM format, it follows these rules: <ul> <li>If the given property is a simple or composite type in the target instance, its property type is returned</li> <li>Otherwise, if it is a composite type, the component type is returned</li> </ul>
* @param target
* @param propertyName
* @return the property type
*/
@SuppressWarnings("rawtypes") public static Class<?> getStructureType(@NonNull final Object destination,@NotEmpty final String propertyName){
Type targetType=getType(destination,propertyName);
if (targetType instanceof Class) {
return (Class)targetType;
}
if (targetType instanceof ParameterizedType) {
ParameterizedType parameterizedType=(ParameterizedType)targetType;
if (parameterizedType.getRawType() == List.class) {
return (Class)parameterizedType.getActualTypeArguments()[0];
}
}
return Ensure.that().fail("Unsupported type %s for propertyName %s in object %s",targetType,(Object)propertyName,destination);
}

Example 10

From project conversation, under directory /spi/src/main/java/org/jboss/seam/conversation/spi/.