Search in sources :

Example 16 with ModelType

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

the class AbstractTemplate method isSupportedClass.

/**
 * Check if the given Class {@code type} is found in the Model.
 *
 * @param type
 *            Class to check support for
 * @return True if supported by this PolymerTemplate
 */
public boolean isSupportedClass(Class<?> type) {
    List<ModelType> modelTypes = ModelDescriptor.get(getModelType()).getPropertyNames().map(this::getModelType).collect(Collectors.toList());
    boolean result = false;
    for (ModelType modelType : modelTypes) {
        if (type.equals(modelType.getJavaType())) {
            result = true;
        } else if (modelType instanceof ListModelType) {
            result = checkListType(type, modelType);
        }
        if (result) {
            break;
        }
    }
    return result;
}
Also used : ListModelType(com.vaadin.flow.templatemodel.ListModelType) BeanModelType(com.vaadin.flow.templatemodel.BeanModelType) ListModelType(com.vaadin.flow.templatemodel.ListModelType) ModelType(com.vaadin.flow.templatemodel.ModelType)

Aggregations

ModelType (com.vaadin.flow.templatemodel.ModelType)16 StateNode (com.vaadin.flow.internal.StateNode)7 BasicModelType (com.vaadin.flow.templatemodel.BasicModelType)6 ModelMap (com.vaadin.flow.internal.nodefeature.ModelMap)5 BeanModelType (com.vaadin.flow.templatemodel.BeanModelType)4 ListModelType (com.vaadin.flow.templatemodel.ListModelType)4 ParameterizedType (java.lang.reflect.ParameterizedType)4 Type (java.lang.reflect.Type)4 BeanModelType (com.vaadin.flow.template.angular.model.BeanModelType)3 ComplexModelType (com.vaadin.flow.templatemodel.ComplexModelType)3 InvalidTemplateModelException (com.vaadin.flow.templatemodel.InvalidTemplateModelException)3 Test (org.junit.Test)3 UI (com.vaadin.flow.component.UI)2 PolymerTemplate (com.vaadin.flow.component.polymertemplate.PolymerTemplate)2 ListModelType (com.vaadin.flow.template.angular.model.ListModelType)2 TemplateElementStateProvider (com.vaadin.flow.dom.impl.TemplateElementStateProvider)1 ReflectTools (com.vaadin.flow.internal.ReflectTools)1 ModelList (com.vaadin.flow.internal.nodefeature.ModelList)1 TemplateMap (com.vaadin.flow.internal.nodefeature.TemplateMap)1 JsExpressionBindingProvider (com.vaadin.flow.template.angular.JsExpressionBindingProvider)1