use of com.vaadin.flow.templatemodel.ListModelType in project flow by vaadin.
the class PolymerTemplate method getModelType.
/**
* Get the {@code ModelType} for given class.
*
* @param type
* Type to get the ModelType for
* @return ModelType for given Type
*/
public ModelType getModelType(Type type) {
List<ModelType> modelTypes = ModelDescriptor.get(getModelType()).getPropertyNames().map(this::getModelType).collect(Collectors.toList());
for (ModelType mtype : modelTypes) {
if (type.equals(mtype.getJavaType())) {
return mtype;
} else if (mtype instanceof ListModelType) {
ModelType modelType = getModelTypeForListModel(type, mtype);
if (modelType != null) {
return modelType;
}
}
}
String msg = String.format("Couldn't find ModelType for requested class %s", type.getTypeName());
throw new IllegalArgumentException(msg);
}
use of com.vaadin.flow.templatemodel.ListModelType in project flow by vaadin.
the class PolymerTemplate 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;
}
use of com.vaadin.flow.templatemodel.ListModelType in project flow by vaadin.
the class AbstractTemplate method getModelType.
/**
* Get the {@code ModelType} for given class.
*
* @param type
* Type to get the ModelType for
* @return ModelType for given Type
*/
public ModelType getModelType(Type type) {
List<ModelType> modelTypes = ModelDescriptor.get(getModelType()).getPropertyNames().map(this::getModelType).collect(Collectors.toList());
for (ModelType mtype : modelTypes) {
if (type.equals(mtype.getJavaType())) {
return mtype;
} else if (mtype instanceof ListModelType) {
ModelType modelType = getModelTypeForListModel(type, mtype);
if (modelType != null) {
return modelType;
}
}
}
String msg = String.format("Couldn't find ModelType for requested class %s", type.getTypeName());
throw new IllegalArgumentException(msg);
}
use of com.vaadin.flow.templatemodel.ListModelType 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;
}
Aggregations