#2914 - Refactor ProcessingContext.getPropertyType() internals and whitespace

This commit is contained in:
Rob Bygrave
2022-12-08 11:37:10 +13:00
parent d2f629e7bb
commit 0e9b83a1ce
2 changed files with 21 additions and 36 deletions
@@ -168,7 +168,6 @@ class ProcessingContext implements Constants {
* Recursively gather all the fields (properties) for the given bean element.
*/
private void gatherProperties(List<VariableElement> fields, Element element) {
TypeElement typeElement = (TypeElement) element;
TypeMirror superclass = typeElement.getSuperclass();
Element mappedSuper = typeUtils.asElement(superclass);
@@ -262,9 +261,17 @@ class ProcessingContext implements Constants {
}
PropertyType getPropertyType(VariableElement field) {
TypeMirror typeMirror = field.asType();
if (dbJsonField(field)) {
return propertyTypeMap.getDbJsonType();
}
if (dbArrayField(field)) {
// get generic parameter type
DeclaredType declaredType = (DeclaredType) field.asType();
String fullType = typeDef(declaredType.getTypeArguments().get(0));
String shortName = langShortType(Split.shortName(fullType));
return new PropertyTypeArray(fullType, shortName);
}
final TypeMirror typeMirror = field.asType();
TypeMirror currentType = typeMirror;
while (currentType != null) {
PropertyType type = propertyTypeMap.getType(typeDef(currentType));
@@ -277,18 +284,6 @@ class ProcessingContext implements Constants {
currentType = (fieldType == null) ? null : fieldType.getSuperclass();
}
if (dbJsonField(field)) {
return propertyTypeMap.getDbJsonType();
}
if (dbArrayField(field)) {
// get generic parameter type
DeclaredType declaredType = (DeclaredType) typeMirror;
String fullType = typeDef(declaredType.getTypeArguments().get(0));
String shortName = langShortType(Split.shortName(fullType));
return new PropertyTypeArray(fullType, shortName);
}
Element fieldType = typeUtils.asElement(typeMirror);
if (fieldType == null) {
return null;
@@ -392,7 +387,6 @@ class ProcessingContext implements Constants {
* Create the QAssoc PropertyType.
*/
private PropertyType createPropertyTypeAssoc(String fullName) {
String[] split = Split.split(fullName);
String propertyName = "QAssoc" + split[1];
String packageName = packageAppend(split[0]);
@@ -445,7 +439,6 @@ class ProcessingContext implements Constants {
* Register an entity with optional dbName.
*/
void addEntity(String beanFullName, String dbName) {
loaded.add(beanFullName);
final String pkg = packageOf(beanFullName);
if (pkg != null) {
@@ -125,7 +125,6 @@ class ProcessingContext implements Constants {
* Recursively gather all the fields (properties) for the given bean element.
*/
private void gatherProperties(List<VariableElement> fields, Element element) {
TypeElement typeElement = (TypeElement) element;
TypeMirror superclass = typeElement.getSuperclass();
Element mappedSuper = typeUtils.asElement(superclass);
@@ -240,9 +239,16 @@ class ProcessingContext implements Constants {
}
PropertyType getPropertyType(VariableElement field) {
TypeMirror typeMirror = field.asType();
if (dbJsonField(field)) {
return propertyTypeMap.getDbJsonType();
}
if (dbArrayField(field)) {
// get generic parameter type
DeclaredType declaredType = (DeclaredType) field.asType();
String fullType = typeDef(declaredType.getTypeArguments().get(0));
return new PropertyTypeArray(fullType, Split.shortName(fullType));
}
final TypeMirror typeMirror = field.asType();
TypeMirror currentType = typeMirror;
while (currentType != null) {
PropertyType type = propertyTypeMap.getType(typeDef(currentType));
@@ -255,17 +261,6 @@ class ProcessingContext implements Constants {
currentType = (fieldType == null) ? null : fieldType.getSuperclass();
}
if (dbJsonField(field)) {
return propertyTypeMap.getDbJsonType();
}
if (dbArrayField(field)) {
// get generic parameter type
DeclaredType declaredType = (DeclaredType) typeMirror;
String fullType = typeDef(declaredType.getTypeArguments().get(0));
return new PropertyTypeArray(fullType, Split.shortName(fullType));
}
Element fieldType = typeUtils.asElement(typeMirror);
if (fieldType == null) {
return null;
@@ -273,7 +268,6 @@ class ProcessingContext implements Constants {
// workaround for https://bugs.eclipse.org/bugs/show_bug.cgi?id=544288
fieldType = elementUtils.getTypeElement(fieldType.toString());
if (fieldType.getKind() == ElementKind.ENUM) {
String fullType = typeDef(typeMirror);
return new PropertyTypeEnum(fullType, Split.shortName(fullType));
@@ -366,7 +360,6 @@ class ProcessingContext implements Constants {
* Create the QAssoc PropertyType.
*/
private PropertyType createPropertyTypeAssoc(String fullName) {
String[] split = Split.split(fullName);
String propertyName = "QAssoc" + split[1];
String packageName = packageAppend(split[0]);
@@ -423,7 +416,6 @@ class ProcessingContext implements Constants {
* Register an entity with optional dbName.
*/
void addEntity(String beanFullName, String dbName) {
loaded.add(beanFullName);
final String pkg = packageOf(beanFullName);
if (pkg != null) {