Search in sources :

Example 1 with ComplexModelType

use of com.vaadin.flow.templatemodel.ComplexModelType in project flow by vaadin.

the class BeanModelType method getListModelType.

private static ModelType getListModelType(Type propertyType, PropertyFilter propertyFilter, String propertyName, Class<?> declaringClass) {
    assert ListModelType.isList(propertyType);
    ParameterizedType pt = (ParameterizedType) propertyType;
    Type itemType = pt.getActualTypeArguments()[0];
    if (itemType instanceof ParameterizedType) {
        return new ListModelType<>((ComplexModelType<?>) getModelType(itemType, propertyFilter, propertyName, declaringClass));
    } else {
        if (!(itemType instanceof Class<?>)) {
            throw new InvalidTemplateModelException("Element type " + itemType.getTypeName() + " is not a valid Bean type. Used in class " + declaringClass.getSimpleName() + " with property named " + propertyName + " with list type " + propertyType.getTypeName());
        }
        Class<?> beansListItemType = (Class<?>) itemType;
        return new ListModelType<>(new BeanModelType<>(beansListItemType, propertyFilter));
    }
}
Also used : ParameterizedType(java.lang.reflect.ParameterizedType) BasicModelType(com.vaadin.flow.templatemodel.BasicModelType) ModelType(com.vaadin.flow.templatemodel.ModelType) ParameterizedType(java.lang.reflect.ParameterizedType) Type(java.lang.reflect.Type) ComplexModelType(com.vaadin.flow.templatemodel.ComplexModelType) InvalidTemplateModelException(com.vaadin.flow.templatemodel.InvalidTemplateModelException)

Aggregations

BasicModelType (com.vaadin.flow.templatemodel.BasicModelType)1 ComplexModelType (com.vaadin.flow.templatemodel.ComplexModelType)1 InvalidTemplateModelException (com.vaadin.flow.templatemodel.InvalidTemplateModelException)1 ModelType (com.vaadin.flow.templatemodel.ModelType)1 ParameterizedType (java.lang.reflect.ParameterizedType)1 Type (java.lang.reflect.Type)1