[FEAT] continue refacto of the generation code
This commit is contained in:
parent
6031e6e557
commit
7a36580cce
1
pom.xml
1
pom.xml
@ -5,6 +5,7 @@
|
|||||||
<artifactId>archidata</artifactId>
|
<artifactId>archidata</artifactId>
|
||||||
<version>0.8.11-SNAPSHOT</version>
|
<version>0.8.11-SNAPSHOT</version>
|
||||||
<properties>
|
<properties>
|
||||||
|
<java.version>21</java.version>
|
||||||
<maven.compiler.version>3.1</maven.compiler.version>
|
<maven.compiler.version>3.1</maven.compiler.version>
|
||||||
<maven.compiler.source>21</maven.compiler.source>
|
<maven.compiler.source>21</maven.compiler.source>
|
||||||
<maven.compiler.target>21</maven.compiler.target>
|
<maven.compiler.target>21</maven.compiler.target>
|
||||||
|
@ -8,7 +8,6 @@ import java.io.InputStreamReader;
|
|||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
import java.lang.reflect.Parameter;
|
import java.lang.reflect.Parameter;
|
||||||
import java.lang.reflect.ParameterizedType;
|
import java.lang.reflect.ParameterizedType;
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Comparator;
|
import java.util.Comparator;
|
||||||
@ -174,22 +173,8 @@ public class DataFactoryTsApi {
|
|||||||
produces = null;
|
produces = null;
|
||||||
} else if (returnTypeModelRaw == Map.class) {
|
} else if (returnTypeModelRaw == Map.class) {
|
||||||
LOGGER.warn("Not manage the Map Model ... set any");
|
LOGGER.warn("Not manage the Map Model ... set any");
|
||||||
final ParameterizedType listType = (ParameterizedType) method.getGenericReturnType();
|
returnTypeModel = new Class<?>[] { Map.class };
|
||||||
final Type typeKey = listType.getActualTypeArguments()[0];
|
tmpReturn = DataFactoryZod.createTables(returnTypeModel, previous);
|
||||||
final Type typeValue = listType.getActualTypeArguments()[1];
|
|
||||||
if (typeKey == String.class) {
|
|
||||||
if (typeValue instanceof ParameterizedType) {
|
|
||||||
final Type typeSubKey = listType.getActualTypeArguments()[0];
|
|
||||||
final Type typeSubValue = listType.getActualTypeArguments()[1];
|
|
||||||
if (typeKey == String.class) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOGGER.warn("Not manage the Map Model ... set any");
|
|
||||||
returnTypeModel = new Class<?>[] { Map.class };
|
|
||||||
tmpReturn = DataFactoryZod.createTables(returnTypeModel, previous);
|
|
||||||
}
|
|
||||||
} else if (returnTypeModelRaw == List.class) {
|
} else if (returnTypeModelRaw == List.class) {
|
||||||
final ParameterizedType listType = (ParameterizedType) method.getGenericReturnType();
|
final ParameterizedType listType = (ParameterizedType) method.getGenericReturnType();
|
||||||
returnTypeModelRaw = (Class<?>) listType.getActualTypeArguments()[0];
|
returnTypeModelRaw = (Class<?>) listType.getActualTypeArguments()[0];
|
||||||
|
@ -24,7 +24,7 @@ public class ApiGroupModel {
|
|||||||
// Origin class reference
|
// Origin class reference
|
||||||
Class<?> originClass;
|
Class<?> originClass;
|
||||||
// List of all API
|
// List of all API
|
||||||
public List<ApiModel> interfaces;
|
public List<ApiModel> interfaces = new ArrayList<>();
|
||||||
|
|
||||||
public ApiGroupModel(final Class<?> clazz, final ModelGroup previousModel) throws Exception {
|
public ApiGroupModel(final Class<?> clazz, final ModelGroup previousModel) throws Exception {
|
||||||
this.originClass = clazz;
|
this.originClass = clazz;
|
||||||
|
@ -10,13 +10,9 @@ import java.util.HashMap;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.kar.archidata.dataAccess.DataFactoryZod;
|
|
||||||
import org.kar.archidata.dataAccess.DataFactoryZod.ClassElement;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
import org.slf4j.LoggerFactory;
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
import jakarta.ws.rs.core.Response;
|
|
||||||
|
|
||||||
public class ApiModel {
|
public class ApiModel {
|
||||||
static final Logger LOGGER = LoggerFactory.getLogger(ApiModel.class);
|
static final Logger LOGGER = LoggerFactory.getLogger(ApiModel.class);
|
||||||
|
|
||||||
@ -46,10 +42,10 @@ public class ApiModel {
|
|||||||
// Possible output type of the REST API
|
// Possible output type of the REST API
|
||||||
public List<String> produces = new ArrayList<>();
|
public List<String> produces = new ArrayList<>();
|
||||||
|
|
||||||
private void updateReturnTypes(final Method method, final ModelGroup previousModel) {
|
private void updateReturnTypes(final Method method, final ModelGroup previousModel) throws Exception {
|
||||||
// get return type from the user specification:
|
// get return type from the user specification:
|
||||||
final Class<?>[] returnTypeModel = ApiTool.apiAnnotationGetAsyncType(method);
|
final Class<?>[] returnTypeModel = ApiTool.apiAnnotationGetAsyncType(method);
|
||||||
|
LOGGER.info("Get return Type async = {}", returnTypeModel);
|
||||||
if (returnTypeModel != null) {
|
if (returnTypeModel != null) {
|
||||||
if (returnTypeModel.length == 0) {
|
if (returnTypeModel.length == 0) {
|
||||||
throw new IOException("Create a @AsyncType with empty elements ...");
|
throw new IOException("Create a @AsyncType with empty elements ...");
|
||||||
@ -69,19 +65,25 @@ public class ApiModel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Class<?> returnTypeModelRaw = method.getReturnType();
|
final Class<?> returnTypeModelRaw = method.getReturnType();
|
||||||
LOGGER.info("Get type: {}", returnTypeModelRaw);
|
LOGGER.info("Get return Type RAW = {}", returnTypeModelRaw.getCanonicalName());
|
||||||
if (returnTypeModelRaw == Map.class) {
|
if (returnTypeModelRaw == Map.class) {
|
||||||
LOGGER.warn("Not manage the Map Model ... set any");
|
LOGGER.warn("Model Map");
|
||||||
final ParameterizedType listType = (ParameterizedType) method.getGenericReturnType();
|
final ParameterizedType listType = (ParameterizedType) method.getGenericReturnType();
|
||||||
this.returnTypes.add(new ClassMapModel(listType, previousModel));
|
this.returnTypes.add(new ClassMapModel(listType, previousModel));
|
||||||
return;
|
return;
|
||||||
}
|
} else if (returnTypeModelRaw == List.class) {
|
||||||
if (returnTypeModelRaw == List.class) {
|
LOGGER.warn("Model List");
|
||||||
final ParameterizedType listType = (ParameterizedType) method.getGenericReturnType();
|
final ParameterizedType listType = (ParameterizedType) method.getGenericReturnType();
|
||||||
this.returnTypes.add(new ClassListModel(listType, previousModel));
|
this.returnTypes.add(new ClassListModel(listType, previousModel));
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
LOGGER.warn("Model Object");
|
||||||
|
this.returnTypes.add(previousModel.add(returnTypeModelRaw));
|
||||||
|
}
|
||||||
|
LOGGER.warn("List of returns elements:");
|
||||||
|
for (final ClassModel elem : this.returnTypes) {
|
||||||
|
LOGGER.warn(" - {}", elem);
|
||||||
}
|
}
|
||||||
this.returnTypes.add(previousModel.add(returnTypeModelRaw));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public ApiModel(final Class<?> clazz, final Method method, final String baseRestEndPoint,
|
public ApiModel(final Class<?> clazz, final Method method, final String baseRestEndPoint,
|
||||||
@ -99,80 +101,16 @@ public class ApiModel {
|
|||||||
LOGGER.trace(" [{}] {} => {}/{}", methodType, methodName, baseRestEndPoint, methodPath);
|
LOGGER.trace(" [{}] {} => {}/{}", methodType, methodName, baseRestEndPoint, methodPath);
|
||||||
this.needGenerateProgress = ApiTool.apiAnnotationTypeScriptProgress(method);
|
this.needGenerateProgress = ApiTool.apiAnnotationTypeScriptProgress(method);
|
||||||
|
|
||||||
Class<?>[] returnTypeModel = ApiTool.apiAnnotationGetAsyncType(method);
|
updateReturnTypes(method, previousModel);
|
||||||
boolean isUnmanagedReturnType = false;
|
LOGGER.trace(" return: {}", this.returnTypes.size());
|
||||||
boolean returnModelIsArray = false;
|
for (final ClassModel elem : this.returnTypes) {
|
||||||
List<ClassElement> tmpReturn;
|
LOGGER.trace(" - {}", elem);
|
||||||
if (returnTypeModel == null) {
|
|
||||||
Class<?> returnTypeModelRaw = method.getReturnType();
|
|
||||||
LOGGER.info("Get type: {}", returnTypeModelRaw);
|
|
||||||
if (returnTypeModelRaw == Response.class) {
|
|
||||||
LOGGER.info("Get type: {}", returnTypeModelRaw);
|
|
||||||
}
|
|
||||||
if (returnTypeModelRaw == Response.class || returnTypeModelRaw == void.class
|
|
||||||
|| returnTypeModelRaw == Void.class) {
|
|
||||||
if (returnTypeModelRaw == Response.class) {
|
|
||||||
isUnmanagedReturnType = true;
|
|
||||||
}
|
|
||||||
returnTypeModel = new Class<?>[] { Void.class };
|
|
||||||
tmpReturn = new ArrayList<>();
|
|
||||||
this.produces = null;
|
|
||||||
} else if (returnTypeModelRaw == Map.class) {
|
|
||||||
LOGGER.warn("Not manage the Map Model ... set any");
|
|
||||||
final ParameterizedType listType = (ParameterizedType) method.getGenericReturnType();
|
|
||||||
final Type typeKey = listType.getActualTypeArguments()[0];
|
|
||||||
final Type typeValue = listType.getActualTypeArguments()[1];
|
|
||||||
if (typeKey == String.class) {
|
|
||||||
if (typeValue instanceof ParameterizedType) {
|
|
||||||
final Type typeSubKey = listType.getActualTypeArguments()[0];
|
|
||||||
final Type typeSubValue = listType.getActualTypeArguments()[1];
|
|
||||||
if (typeKey == String.class) {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
LOGGER.warn("Not manage the Map Model ... set any");
|
|
||||||
returnTypeModel = new Class<?>[] { Map.class };
|
|
||||||
tmpReturn = DataFactoryZod.createTables(returnTypeModel, previous);
|
|
||||||
}
|
|
||||||
} else if (returnTypeModelRaw == List.class) {
|
|
||||||
final ParameterizedType listType = (ParameterizedType) method.getGenericReturnType();
|
|
||||||
returnTypeModelRaw = (Class<?>) listType.getActualTypeArguments()[0];
|
|
||||||
returnModelIsArray = true;
|
|
||||||
returnTypeModel = new Class<?>[] { returnTypeModelRaw };
|
|
||||||
tmpReturn = DataFactoryZod.createTables(returnTypeModel, previous);
|
|
||||||
} else {
|
|
||||||
returnTypeModel = new Class<?>[] { returnTypeModelRaw };
|
|
||||||
tmpReturn = DataFactoryZod.createTables(returnTypeModel, previous);
|
|
||||||
}
|
|
||||||
} else if (returnTypeModel.length >= 0 && (returnTypeModel[0] == Response.class
|
|
||||||
|| returnTypeModel[0] == Void.class || returnTypeModel[0] == void.class)) {
|
|
||||||
if (returnTypeModel[0] == Response.class) {
|
|
||||||
isUnmanagedReturnType = true;
|
|
||||||
}
|
|
||||||
returnTypeModel = new Class<?>[] { Void.class };
|
|
||||||
tmpReturn = new ArrayList<>();
|
|
||||||
this.produces = null;
|
|
||||||
} else if (returnTypeModel.length > 0 && returnTypeModel[0] == Map.class) {
|
|
||||||
LOGGER.warn("Not manage the Map Model ...");
|
|
||||||
returnTypeModel = new Class<?>[] { Map.class };
|
|
||||||
tmpReturn = DataFactoryZod.createTables(returnTypeModel, previous);
|
|
||||||
} else {
|
|
||||||
tmpReturn = DataFactoryZod.createTables(returnTypeModel, previous);
|
|
||||||
}
|
|
||||||
for (final ClassElement elem : tmpReturn) {
|
|
||||||
includeModel.add(elem.model[0]);
|
|
||||||
includeCheckerModel.add(elem.model[0]);
|
|
||||||
}
|
|
||||||
LOGGER.trace(" return: {}", tmpReturn.size());
|
|
||||||
for (final ClassElement elem : tmpReturn) {
|
|
||||||
LOGGER.trace(" - {}", elem.tsTypeName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final Map<String, String> queryParams = new HashMap<>();
|
final Map<String, List<ClassModel>> queryParams = new HashMap<>();
|
||||||
final Map<String, String> pathParams = new HashMap<>();
|
final Map<String, List<ClassModel>> pathParams = new HashMap<>();
|
||||||
final Map<String, String> formDataParams = new HashMap<>();
|
final Map<String, List<ClassModel>> formDataParams = new HashMap<>();
|
||||||
final List<String> emptyElement = new ArrayList<>();
|
final List<ClassModel> emptyElement = new ArrayList<>();
|
||||||
// LOGGER.info(" Parameters:");
|
// LOGGER.info(" Parameters:");
|
||||||
for (final Parameter parameter : method.getParameters()) {
|
for (final Parameter parameter : method.getParameters()) {
|
||||||
// Security context are internal parameter (not available from API)
|
// Security context are internal parameter (not available from API)
|
||||||
@ -180,59 +118,33 @@ public class ApiModel {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final Class<?> parameterType = parameter.getType();
|
final Class<?> parameterType = parameter.getType();
|
||||||
String parameterTypeString;
|
final List<ClassModel> parameterModel = new ArrayList<>();
|
||||||
final Class<?>[] asyncType = ApiTool.apiAnnotationGetAsyncType(parameter);
|
final Class<?>[] asyncType = ApiTool.apiAnnotationGetAsyncType(parameter);
|
||||||
if (parameterType == List.class) {
|
if (asyncType != null) {
|
||||||
if (asyncType == null) {
|
for (final Class<?> elem : asyncType) {
|
||||||
LOGGER.warn("Detect List param ==> not managed type ==> any[] !!!");
|
parameterModel.add(new ClassListModel(elem, previousModel));
|
||||||
parameterTypeString = "any[]";
|
|
||||||
} else {
|
|
||||||
final List<ClassElement> tmp = DataFactoryZod.createTables(asyncType, previous);
|
|
||||||
for (final ClassElement elem : tmp) {
|
|
||||||
includeModel.add(elem.model[0]);
|
|
||||||
}
|
|
||||||
parameterTypeString = ApiTool.convertInTypeScriptType(tmp, true);
|
|
||||||
}
|
}
|
||||||
} else if (asyncType == null) {
|
} else if (parameterType == List.class) {
|
||||||
final ClassElement tmp = DataFactoryZod.createTable(parameterType, previous);
|
final Type parameterrizedType = parameter.getParameterizedType();
|
||||||
includeModel.add(tmp.model[0]);
|
parameterModel.add(ClassModel.getModelBase(parameterType, parameterrizedType, previousModel));
|
||||||
parameterTypeString = tmp.tsTypeName;
|
} else if (parameterType == Map.class) {
|
||||||
|
final Type parameterrizedType = parameter.getParameterizedType();
|
||||||
|
parameterModel.add(ClassModel.getModelBase(parameterType, parameterrizedType, previousModel));
|
||||||
} else {
|
} else {
|
||||||
final List<ClassElement> tmp = DataFactoryZod.createTables(asyncType, previous);
|
parameterModel.add(ClassModel.getModel(parameterType, previousModel));
|
||||||
for (final ClassElement elem : tmp) {
|
|
||||||
includeModel.add(elem.model[0]);
|
|
||||||
}
|
|
||||||
parameterTypeString = ApiTool.convertInTypeScriptType(tmp, true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
final String pathParam = ApiTool.apiAnnotationGetPathParam(parameter);
|
final String pathParam = ApiTool.apiAnnotationGetPathParam(parameter);
|
||||||
final String queryParam = ApiTool.apiAnnotationGetQueryParam(parameter);
|
final String queryParam = ApiTool.apiAnnotationGetQueryParam(parameter);
|
||||||
final String formDataParam = ApiTool.apiAnnotationGetFormDataParam(parameter);
|
final String formDataParam = ApiTool.apiAnnotationGetFormDataParam(parameter);
|
||||||
if (queryParam != null) {
|
if (queryParam != null) {
|
||||||
queryParams.put(queryParam, parameterTypeString);
|
queryParams.put(queryParam, parameterModel);
|
||||||
} else if (pathParam != null) {
|
} else if (pathParam != null) {
|
||||||
pathParams.put(pathParam, parameterTypeString);
|
pathParams.put(pathParam, parameterModel);
|
||||||
} else if (formDataParam != null) {
|
} else if (formDataParam != null) {
|
||||||
formDataParams.put(formDataParam, parameterTypeString);
|
formDataParams.put(formDataParam, parameterModel);
|
||||||
} else if (asyncType != null) {
|
|
||||||
final List<ClassElement> tmp = DataFactoryZod.createTables(asyncType, previous);
|
|
||||||
parameterTypeString = "";
|
|
||||||
for (final ClassElement elem : tmp) {
|
|
||||||
includeModel.add(elem.model[0]);
|
|
||||||
if (parameterTypeString.length() != 0) {
|
|
||||||
parameterTypeString += " | ";
|
|
||||||
}
|
|
||||||
parameterTypeString += elem.tsTypeName;
|
|
||||||
}
|
|
||||||
emptyElement.add(parameterTypeString);
|
|
||||||
} else if (parameterType == List.class) {
|
|
||||||
parameterTypeString = "any[]";
|
|
||||||
final Class<?> plop = parameterType.arrayType();
|
|
||||||
LOGGER.info("ArrayType = {}", plop);
|
|
||||||
emptyElement.add(parameterTypeString);
|
|
||||||
} else {
|
} else {
|
||||||
final ClassElement tmp = DataFactoryZod.createTable(parameterType, previous);
|
emptyElement.addAll(parameterModel);
|
||||||
includeModel.add(tmp.model[0]);
|
|
||||||
emptyElement.add(tmp.tsTypeName);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,4 +5,15 @@ public class ClassEnumModel extends ClassModel {
|
|||||||
protected ClassEnumModel(final Class<?> clazz) {
|
protected ClassEnumModel(final Class<?> clazz) {
|
||||||
this.originClasses.add(clazz);
|
this.originClasses.add(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
final StringBuilder out = new StringBuilder();
|
||||||
|
out.append("ClassEnumModel [");
|
||||||
|
for (final Class<?> elem : this.originClasses) {
|
||||||
|
out.append(elem.getCanonicalName());
|
||||||
|
}
|
||||||
|
out.append("]");
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,9 +11,18 @@ public class ClassListModel extends ClassModel {
|
|||||||
this.valueModel = valueModel;
|
this.valueModel = valueModel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ClassListModel(final Class<?> clazz, final ModelGroup previousModel) throws IOException {
|
||||||
|
this.valueModel = getModel(clazz, previousModel);
|
||||||
|
}
|
||||||
|
|
||||||
public ClassListModel(final ParameterizedType listType, final ModelGroup previousModel) throws IOException {
|
public ClassListModel(final ParameterizedType listType, final ModelGroup previousModel) throws IOException {
|
||||||
final Type model = listType.getActualTypeArguments()[0];
|
final Type model = listType.getActualTypeArguments()[0];
|
||||||
this.valueModel = getModel(model, previousModel);
|
this.valueModel = getModel(model, previousModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ClassListModel [valueModel=" + this.valueModel + "]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -17,4 +17,9 @@ public class ClassMapModel extends ClassModel {
|
|||||||
this.valueModel = getModel(listType.getActualTypeArguments()[1], previousModel);
|
this.valueModel = getModel(listType.getActualTypeArguments()[1], previousModel);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return "ClassMapModel [keyModel=" + this.keyModel + ", valueModel=" + this.valueModel + "]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ public abstract class ClassModel {
|
|||||||
return this.originClasses.contains(clazz);
|
return this.originClasses.contains(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClassModel getModel(final Type type, final ModelGroup previousModel) throws IOException {
|
public static ClassModel getModel(final Type type, final ModelGroup previousModel) throws IOException {
|
||||||
if (type == List.class) {
|
if (type == List.class) {
|
||||||
if (type instanceof final ParameterizedType parameterizedType) {
|
if (type instanceof final ParameterizedType parameterizedType) {
|
||||||
return new ClassListModel(parameterizedType, previousModel);
|
return new ClassListModel(parameterizedType, previousModel);
|
||||||
@ -32,4 +32,27 @@ public abstract class ClassModel {
|
|||||||
return previousModel.add((Class<?>) type);
|
return previousModel.add((Class<?>) type);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static ClassModel getModelBase(
|
||||||
|
final Class<?> clazz,
|
||||||
|
final Type parameterizedType,
|
||||||
|
final ModelGroup previousModel) throws IOException {
|
||||||
|
if (clazz == List.class) {
|
||||||
|
return new ClassListModel((ParameterizedType) parameterizedType, previousModel);
|
||||||
|
}
|
||||||
|
if (clazz == Map.class) {
|
||||||
|
return new ClassMapModel((ParameterizedType) parameterizedType, previousModel);
|
||||||
|
}
|
||||||
|
return previousModel.add(clazz);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static ClassModel getModel(final Class<?> type, final ModelGroup previousModel) throws IOException {
|
||||||
|
if (type == List.class) {
|
||||||
|
throw new IOException("Fail to manage parametrized type...");
|
||||||
|
}
|
||||||
|
if (type == Map.class) {
|
||||||
|
throw new IOException("Fail to manage parametrized type...");
|
||||||
|
}
|
||||||
|
return previousModel.add(type);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,4 +5,15 @@ public class ClassObjectModel extends ClassModel {
|
|||||||
public ClassObjectModel(final Class<?> clazz) {
|
public ClassObjectModel(final Class<?> clazz) {
|
||||||
this.originClasses.add(clazz);
|
this.originClasses.add(clazz);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
final StringBuilder out = new StringBuilder();
|
||||||
|
out.append("ClassObjectModel [");
|
||||||
|
for (final Class<?> elem : this.originClasses) {
|
||||||
|
out.append(elem.getCanonicalName());
|
||||||
|
}
|
||||||
|
out.append("]");
|
||||||
|
return out.toString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,11 @@ package org.kar.archidata.externalRestApi.model;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import org.slf4j.Logger;
|
||||||
|
import org.slf4j.LoggerFactory;
|
||||||
|
|
||||||
public class ModelGroup {
|
public class ModelGroup {
|
||||||
|
static final Logger LOGGER = LoggerFactory.getLogger(ModelGroup.class);
|
||||||
public List<ClassModel> previousModel = new ArrayList<>();
|
public List<ClassModel> previousModel = new ArrayList<>();
|
||||||
|
|
||||||
public ModelGroup() {}
|
public ModelGroup() {}
|
||||||
@ -13,16 +17,23 @@ public class ModelGroup {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ClassModel add(final Class<?> clazz) {
|
public ClassModel add(final Class<?> clazz) {
|
||||||
|
//LOGGER.trace("Search element {}", clazz.getCanonicalName());
|
||||||
for (final ClassModel value : this.previousModel) {
|
for (final ClassModel value : this.previousModel) {
|
||||||
if (value.isCompatible(clazz)) {
|
if (value.isCompatible(clazz)) {
|
||||||
|
//LOGGER.trace(" ==> return {}", value);
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (clazz.isEnum()) {
|
if (clazz.isEnum()) {
|
||||||
final ClassModel elem = new ClassEnumModel(clazz);
|
final ClassModel elem = new ClassEnumModel(clazz);
|
||||||
|
this.previousModel.add(elem);
|
||||||
|
//LOGGER.trace(" ==> return enum {}", elem);
|
||||||
|
return elem;
|
||||||
}
|
}
|
||||||
// create new model:
|
// create new model:
|
||||||
|
final ClassModel elem = new ClassObjectModel(clazz);
|
||||||
return null;
|
this.previousModel.add(elem);
|
||||||
|
//LOGGER.trace(" ==> return object {}", elem);
|
||||||
|
return elem;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user