Fields generation for custom datatypes with possibility of overloading

This commit is contained in:
Alexey Prudnikov 2018-08-14 14:06:22 +03:00 committed by Gleb Gorelov
parent d2b609f21b
commit 14d75546f0

View File

@ -63,7 +63,10 @@ public abstract class AbstractComponentGenerationStrategy implements ComponentGe
MetaPropertyPath mpp = resolveMetaPropertyPath(metaClass, context.getProperty());
Element xmlDescriptor = context.getXmlDescriptor();
if (mpp != null) {
if (mpp == null) {
return null;
}
Range mppRange = mpp.getRange();
if (mppRange.isDatatype()) {
Class type = mppRange.asDatatype().getJavaClass();
@ -79,16 +82,13 @@ public abstract class AbstractComponentGenerationStrategy implements ComponentGe
if (xmlDescriptor != null
&& "true".equalsIgnoreCase(xmlDescriptor.attributeValue("link"))) {
return createDatatypeLinkField(context);
} else {
}
boolean hasMaskAttribute = xmlDescriptor != null
&& xmlDescriptor.attribute("mask") != null;
if (type.equals(String.class)) {
if (hasMaskAttribute) {
return createMaskedField(context);
} else {
return createStringField(context, mpp);
}
return hasMaskAttribute ? createMaskedField(context) : createStringField(context, mpp);
} else if (type.equals(UUID.class)) {
return createUuidField(context);
} else if (type.equals(Boolean.class)) {
@ -100,16 +100,18 @@ public abstract class AbstractComponentGenerationStrategy implements ComponentGe
} else if (Number.class.isAssignableFrom(type)) {
if (hasMaskAttribute) {
return createMaskedField(context);
} else {
}
Field currencyField = createCurrencyField(context, mpp);
if (currencyField != null) {
return currencyField;
}
return createNumberField(context);
}
}
}
return createCustomDatatypeField(context, type, mpp);
} else if (mppRange.isClass()) {
MetaProperty metaProperty = mpp.getMetaProperty();
Class<?> javaType = metaProperty.getJavaType();
@ -124,7 +126,6 @@ public abstract class AbstractComponentGenerationStrategy implements ComponentGe
} else if (mppRange.isEnum()) {
return createEnumField(context);
}
}
return null;
}
@ -376,6 +377,10 @@ public abstract class AbstractComponentGenerationStrategy implements ComponentGe
}
}
protected Component createCustomDatatypeField(ComponentGenerationContext context, Class dataType, MetaPropertyPath mpp) {
return createStringField(context, mpp);
}
protected void setLinkFieldAttributes(EntityLinkField linkField, ComponentGenerationContext context) {
Element xmlDescriptor = context.getXmlDescriptor();
if (xmlDescriptor != null) {