Compare commits

..

No commits in common. "dev" and "main" have entirely different histories.
dev ... main

46 changed files with 177 additions and 2753 deletions

26
.classpath Normal file
View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry including="**/*.java" kind="src" output="out/eclipse/classes-test" path="test/src">
<attributes>
<attribute name="test" value="true"/>
<attribute name="optional" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="src" path="src"/>
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/5">
<attributes>
<attribute name="test" value="true"/>
</attributes>
</classpathentry>
<classpathentry combineaccessrules="false" exported="true" kind="src" path="/atriasoft-etk">
<attributes>
<attribute name="module" value="true"/>
</attributes>
</classpathentry>
<classpathentry kind="output" path="out/eclipse/classes"/>
</classpath>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="org.eclipse.ant.AntBuilderLaunchConfigurationType">
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_BUILDER_ENABLED" value="false"/>
<stringAttribute key="org.eclipse.ui.externaltools.ATTR_DISABLED_BUILDER" value="net.sf.eclipsecs.core.CheckstyleBuilder"/>
<mapAttribute key="org.eclipse.ui.externaltools.ATTR_TOOL_ARGUMENTS"/>
<booleanAttribute key="org.eclipse.ui.externaltools.ATTR_TRIGGERS_CONFIGURED" value="true"/>
</launchConfiguration>

35
.project Normal file
View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>atriasoft-aknot</name>
<comment></comment>
<projects>
<project>atriasoft-aknot</project>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
<buildCommand>
<name>net.sf.eclipsecs.core.CheckstyleBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
<nature>net.sf.eclipsecs.core.CheckstyleNature</nature>
</natures>
<filteredResources>
<filter>
<id>1646149232194</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

128
pom.xml
View File

@ -1,128 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.atriasoft</groupId>
<artifactId>aknot</artifactId>
<version>0.1.0</version>
<licenses>
<license>
<name>Mozilla Public License 2.0</name>
<url>https://opensource.org/licenses/MPL-2.0</url>
<distribution>repo</distribution>
</license>
</licenses>
<developers>
<developer>
<id>dev1</id>
<name>Edouard DUPIN</name>
<email>edouard.dupin@proton.me</email>
<roles>
<role>Lead Developer</role>
</roles>
</developer>
</developers>
<repositories>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
</repositories>
<distributionManagement>
<repository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</repository>
<snapshotRepository>
<id>gitea</id>
<url>https://gitea.atria-soft.org/api/packages/org.atriasoft/maven</url>
</snapshotRepository>
</distributionManagement>
<dependencies>
<dependency>
<groupId>org.atriasoft</groupId>
<artifactId>etk</artifactId>
<version>0.1.0</version>
</dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-api</artifactId>
<version>5.11.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<sourceDirectory>src/main</sourceDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.14.0</version>
<configuration>
<source>21</source>
<target>21</target>
</configuration>
</plugin>
<!-- Create the source bundle -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<version>3.3.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
</plugin>
<!-- junit results -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.2.5</version>
</plugin>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>fully.qualified.MainClass</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
<!-- Java-doc generation for stand-alone site -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<show>private</show>
<nohelp>true</nohelp>
</configuration>
</plugin>
</plugins>
</build>
<!-- Generate Java-docs As Part Of Project Reports -->
<reporting>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<show>public</show>
</configuration>
</plugin>
</plugins>
</reporting>
</project>

View File

@ -1,230 +0,0 @@
package org.atriasoft.aknot;
import java.util.HashMap;
import java.util.Map;
import org.atriasoft.aknot.model.StringConverter;
public class StringSerializer {
private static final Map<Class<?>, StringConverter> VALUES_OF = new HashMap<>();
static {
StringSerializer.VALUES_OF.put(byte.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Byte.toString((Byte) data);
}
@Override
public Object valueOf(final String value) {
return Byte.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(Byte.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Byte.toString((Byte) data);
}
@Override
public Object valueOf(final String value) {
return Byte.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(int.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Integer.toString((Integer) data);
}
@Override
public Object valueOf(final String value) {
return Integer.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(Integer.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Integer.toString((Integer) data);
}
@Override
public Object valueOf(final String value) {
return Integer.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(long.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Long.toString((Long) data);
}
@Override
public Object valueOf(final String value) {
return Long.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(Long.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Long.toString((Long) data);
}
@Override
public Object valueOf(final String value) {
return Long.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(short.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Short.toString((Short) data);
}
@Override
public Object valueOf(final String value) {
return Short.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(Short.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Short.toString((Short) data);
}
@Override
public Object valueOf(final String value) {
return Short.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(float.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Float.toString((Float) data);
}
@Override
public Object valueOf(final String value) {
return Float.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(Float.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Float.toString((Float) data);
}
@Override
public Object valueOf(final String value) {
return Float.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(double.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Double.toString((Double) data);
}
@Override
public Object valueOf(final String value) {
return Double.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(Double.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Double.toString((Double) data);
}
@Override
public Object valueOf(final String value) {
return Double.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(boolean.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Boolean.toString((Boolean) data);
}
@Override
public Object valueOf(final String value) {
return Boolean.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(Boolean.class, new StringConverter() {
@Override
public String toString(final Object data) {
return Boolean.toString((Boolean) data);
}
@Override
public Object valueOf(final String value) {
return Boolean.valueOf(value.trim());
}
});
StringSerializer.VALUES_OF.put(String.class, new StringConverter() {
@Override
public String toString(final Object data) {
return (String) data;
}
@Override
public Object valueOf(final String value) {
return value;
}
});
}
public static boolean contains(final Class<?> clazz) {
return StringSerializer.VALUES_OF.containsKey(clazz);
}
public static String toString(final boolean data) {
return Boolean.toString(data);
}
public static String toString(final byte data) {
return Byte.toString(data);
}
public static String toString(final int data) {
return Integer.toString(data);
}
public static String toString(final long data) {
return Long.toString(data);
}
/**
* Serialize in a string the require data
* @param data Object to serialize
* @return The new data...
*/
public static String toString(final Object data) {
if (data == null) {
return null;
}
final Class<?> clazz = data.getClass();
final StringConverter conv = StringSerializer.VALUES_OF.get(clazz);
return conv.toString(data);
}
public static String toString(final short data) {
return Short.toString(data);
}
/**
* Un-serialize a String in a specified Object
* @param value String to parse
* @return Data generated or Null
*/
public static Object valueOf(final Class<?> clazz, final String value) {
if (value == null) {
return null;
}
final StringConverter conv = StringSerializer.VALUES_OF.get(clazz);
return conv.valueOf(value);
}
private StringSerializer() {}
}

View File

@ -1,8 +0,0 @@
package org.atriasoft.aknot.model;
import java.lang.reflect.Constructor;
public record ConstructorModel(
String[] values,
Boolean[] isAttributes,
Constructor<?> constructor) {}

View File

@ -1,257 +0,0 @@
package org.atriasoft.aknot.model;
import java.util.List;
import java.util.Map;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.pojo.IntrospectionProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class IntrospectionModel {
final static Logger LOGGER = LoggerFactory.getLogger(IntrospectionModel.class);
public static final String STUPID_TOCKEN = "___aé\"'__-è==**ù!^$:;,;AZEARTYUIOPMLKJHGFDSQW>XCVBN?"; // can not exist ....
protected static final Boolean DEFAULT_ATTRIBUTE = false;
protected static final Boolean DEFAULT_IGNORE_UNBKNOWN = false;
protected static final Boolean DEFAULT_DEFAULT_NULL_VALUE = false;
protected static final Boolean DEFAULT_CASE_SENSITIVE = true;
protected static final Boolean DEFAULT_MANAGED = true;
protected static final Boolean DEFAULT_OPTIONAL = false;
protected boolean defaultNullValue = false;
protected boolean ignoreUnknown = false;
protected final Class<?> classType;
protected String[] names;
public IntrospectionModel(final Class<?> classType) {
this.classType = classType;
this.names = new String[1];
this.names[0] = classType.getSimpleName();
}
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes, final boolean attributeIndependent) throws AknotException {
return null;
}
public List<IntrospectionProperty> getAttributes() {
return null;
}
public String getBeanName(final String nodeName) {
return nodeName;
}
public String getBeanNameModel(final String nodeName) {
return getBeanName(nodeName);
}
public Class<?> getClassType() {
return this.classType;
}
public String[] getNames() {
return this.names;
}
public List<String> getNodeAvaillable() {
return null;
}
public List<IntrospectionProperty> getNodes() {
return null;
}
public List<IntrospectionProperty> getSignals() {
return null;
}
public String getTextBeanName() {
// TODO Auto-generated method stub
return null;
}
public String getTokenBasicList() {
return STUPID_TOCKEN;
}
public String getTreeNameOfSubNode(final String nodeName, final boolean attributeIndependent) throws AknotException {
return null;
}
public Class<?> getTypeOfProperty(final String nodeName) throws AknotException {
return null;
}
public Class<?> getTypeOfSubNode(final String nodeName, final boolean attributeIndependent) throws AknotException {
return null;
}
public Class<?> getTypeOfSubNodeList(final String nodeName, final boolean attributeIndependent) throws AknotException {
return null;
}
public Class<?> getTypeOfSubProperty(final String nodeName) throws AknotException {
return null;
}
public Class<?> getTypeOfText() {
return null;
}
public Object getValue(final String propertyName, final String propertyValue) throws AknotException {
return null;
}
/**
* This converter Number to the correct type ...
*/
public Object getValueConverted(final Object value, final Class<?> classTypeLocal) throws AknotException {
// Note if the type is an Array<>() or a List<>() ==> we parse element by element ... then we need to keep the undertype...
LOGGER.debug("======>>>>>>> convert : {} ==> {} ", value.getClass().getCanonicalName(), classTypeLocal.getCanonicalName());
if (value.getClass() == Long.class) {
if (classTypeLocal == long.class || classTypeLocal == Long.class) {
return value;
}
final Long value2 = (Long) value;
if (classTypeLocal == byte.class || classTypeLocal == Byte.class) {
return value2.byteValue();
}
if (classTypeLocal == short.class || classTypeLocal == Short.class) {
return value2.shortValue();
}
if (classTypeLocal == float.class || classTypeLocal == Float.class) {
return value2.floatValue();
}
if (classTypeLocal == double.class || classTypeLocal == Double.class) {
return value2.doubleValue();
}
if (classTypeLocal == Integer.class || classTypeLocal == int.class) {
return value2.intValue();
}
if (classTypeLocal == boolean.class || classTypeLocal == Boolean.class) {
return value2.equals(0);
}
}
if (value.getClass() == Double.class) {
if (classTypeLocal == double.class || classTypeLocal == Double.class) {
return value;
}
final Double value2 = (Double) value;
if (classTypeLocal == byte.class || classTypeLocal == Byte.class) {
return value2.byteValue();
}
if (classTypeLocal == short.class || classTypeLocal == Short.class) {
return value2.shortValue();
}
if (classTypeLocal == float.class || classTypeLocal == Float.class) {
return value2.floatValue();
}
if (classTypeLocal == long.class || classTypeLocal == Long.class) {
return value2.longValue();
}
if (classTypeLocal == Integer.class || classTypeLocal == int.class) {
return value2.intValue();
}
if (classTypeLocal == boolean.class || classTypeLocal == Boolean.class) {
return !value2.equals(0);
}
}
if (value.getClass() == Boolean.class) {
if (classTypeLocal == boolean.class || classTypeLocal == Boolean.class) {
return value;
}
final Boolean value2 = (Boolean) value;
if (classTypeLocal == byte.class || classTypeLocal == Byte.class) {
if (value2)
return (byte) 1;
else
return (byte) 0;
}
if (classTypeLocal == short.class || classTypeLocal == Short.class) {
if (value2)
return (short) 1;
else
return (short) 0;
}
if (classTypeLocal == float.class || classTypeLocal == Float.class) {
if (value2)
return (float) 1;
else
return (float) 0;
}
if (classTypeLocal == long.class || classTypeLocal == Long.class) {
if (value2)
return (long) 1;
else
return (long) 0;
}
if (classTypeLocal == int.class || classTypeLocal == Integer.class) {
if (value2)
return (int) 1;
else
return (int) 0;
}
if (classTypeLocal == double.class || classTypeLocal == Double.class) {
if (value2)
return (double) 1;
else
return (double) 0;
}
}
LOGGER.error("======>>>>>>> convert : {} ==> {} Can not do it !!!", value.getClass().getCanonicalName(), classTypeLocal.getCanonicalName());
return value;
}
public Object getValueFromText(final String text) throws AknotException {
return null;
}
/**
* This permit to know if an element in the property is able to manage the Whole text under (this remove all parsing of xml inside the model...) Annotation @XmlText
* @return true if a parameter manage the text (otherwise the text is sended to the fromString() function.
*/
public boolean hasTextModel() {
return false;
}
public boolean isArray() {
return false;
}
protected boolean isDefaultNullValue() {
return this.defaultNullValue;
}
public boolean isEnum() {
return this.classType.isEnum();
}
public boolean isIgnoreUnknown() {
return this.ignoreUnknown;
}
public boolean isList() {
return false;
}
public boolean isNative() {
return false;
}
public boolean isObject(final String propertyName) {
return Object.class.isAssignableFrom(this.classType);
}
public boolean isRecord(final String propertyName) {
return Record.class.isAssignableFrom(this.classType);
}
public void setNames(final String[] names) {
this.names = names;
}
public abstract String toString(final Object data) throws AknotException;
}

View File

@ -1,7 +0,0 @@
package org.atriasoft.aknot.model;
import org.atriasoft.aknot.exception.AknotException;
public interface IntrospectionPropertyGetter {
Object getValue(Object object) throws AknotException;
}

View File

@ -1,13 +0,0 @@
package org.atriasoft.aknot.model;
import org.atriasoft.aknot.exception.AknotException;
public interface IntrospectionPropertySetter {
/**
* set the specific string value in the specified object
* @param object Object to add the value
* @param value Value to set in the Object
* @throws Exception An error occurred
*/
void setValue(Object object, Object value) throws AknotException;
}

View File

@ -1,14 +0,0 @@
package org.atriasoft.aknot.model;
public record MapKey (ModelType model,
String nodeName,
Class<?> type) {
public MapKey(final ModelType model, final String nodeName, final Class<?> type) {
this.model = model;
this.nodeName = nodeName;
this.type = type;
}
public MapKey(final ModelType model, final Class<?> type) {
this(model, null, type);
}
}

View File

@ -1,7 +0,0 @@
package org.atriasoft.aknot.model;
public enum ModelType {
NORMAL,
ARRAY,
LIST
}

View File

@ -1,16 +0,0 @@
package org.atriasoft.aknot.model;
public interface StringConverter {
/**
* Un-serialize a String in a specified Object
* @param value String to parse
* @return Data generated or Null
*/
Object valueOf(final String value);
/**
* Serialize in a string the require data
* @param data Object to serialize
* @return The new data...
*/
String toString(final Object data);
}

View File

@ -1,36 +0,0 @@
package org.atriasoft.aknot.pojo;
import java.util.HashMap;
import java.util.Map;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.IntrospectionModel;
import org.atriasoft.aknot.model.MapKey;
import org.atriasoft.aknot.model.ModelType;
public class CacheIntrospectionModel {
final Map<MapKey, IntrospectionModel> elements = new HashMap<>();
public CacheIntrospectionModel() {
}
public IntrospectionModel findOrCreate(final ModelType model, final String name, final Class<?> classType) throws AknotException {
final MapKey key = new MapKey(model, name, classType);
IntrospectionModel out = this.elements.get(key);
if (out != null) {
return out;
}
if (model == ModelType.ARRAY) {
out = IntrospectionModelFactory.createModelArray(key.nodeName(), key);
} else if (model == ModelType.LIST) {
out = IntrospectionModelFactory.createModelList(key.nodeName(), key);
} else if (classType.isEnum()) {
out = IntrospectionModelFactory.createModelEnum(key);
} else {
out = IntrospectionModelFactory.createModel(key);
}
this.elements.put(key, out);
return out;
}
}

View File

@ -1,77 +0,0 @@
package org.atriasoft.aknot.pojo;
import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.IntrospectionModel;
import org.atriasoft.etk.util.ArraysTools;
public class IntrospectionModelArray extends IntrospectionModel {
@SuppressWarnings("unchecked")
public static <T> T[] convertList(final Class<T> classType, final List<Object> data) {
final List<T> rootList = (List<T>) data;
final T[] strarr = (T[]) Array.newInstance(classType, 0);
return rootList.toArray(strarr);
}
final String nodeName;
public IntrospectionModelArray(final String nodeName, final Class<?> classType) {
super(classType);
this.nodeName = nodeName;
}
@Override
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes, final boolean attributeIndependent) throws AknotException {
List<Object> tmp = null;
if (this.nodeName == null) {
tmp = nodes.get(STUPID_TOCKEN);
} else {
tmp = nodes.get(this.nodeName);
}
if (tmp == null) {
return null;
}
if (this.classType.isPrimitive()) {
return ArraysTools.listToPrimitiveAuto(this.classType, tmp);
}
return IntrospectionModelArray.convertList(this.classType, tmp);
}
@Override
public List<String> getNodeAvaillable() {
if (this.nodeName != null) {
return Arrays.asList(this.nodeName);
}
return null;
}
@Override
public Object getValue(final String propertyName, final String propertyValue) throws AknotException {
return null;
}
@Override
public Object getValueFromText(final String text) throws AknotException {
return new Object[0];
}
@Override
public boolean hasTextModel() {
return false;
}
@Override
public boolean isArray() {
return true;
}
@Override
public String toString(final Object data) {
return null;
}
}

View File

@ -1,47 +0,0 @@
package org.atriasoft.aknot.pojo;
import java.util.List;
import java.util.Map;
import org.atriasoft.aknot.StringSerializer;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.IntrospectionModel;
public class IntrospectionModelBaseType extends IntrospectionModel {
public IntrospectionModelBaseType(final Class<?> classType) {
super(classType);
}
@Override
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes, final boolean attributeIndependent) throws AknotException {
throw new AknotException("Base type model can not have properties and nodes ... ");
}
@Override
public List<String> getNodeAvaillable() {
return null;
}
@Override
public Object getValue(final String propertyName, final String propertyValue) throws AknotException {
return null;
}
@Override
public Object getValueFromText(final String text) throws AknotException {
//il y a un bug ici ...
return StringSerializer.valueOf(this.classType, text);
}
@Override
public boolean isNative() {
return true;
}
@Override
public String toString(final Object data) {
return StringSerializer.toString(data);
}
}

View File

@ -1,29 +0,0 @@
package org.atriasoft.aknot.pojo;
import org.atriasoft.aknot.StringSerializer;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.IntrospectionModel;
import org.atriasoft.aknot.model.MapKey;
public class IntrospectionModelFactory {
public static IntrospectionModel createModel(final MapKey modelType) throws AknotException {
if (StringSerializer.contains(modelType.type())) {
return new IntrospectionModelBaseType(modelType.type());
}
return new IntrospectionModelComplex(modelType.type());
}
public static IntrospectionModel createModelArray(final String nodeName, final MapKey modelType) throws AknotException {
return new IntrospectionModelArray(nodeName, modelType.type());
}
public static IntrospectionModel createModelEnum(final MapKey modelType) throws AknotException {
return new IntrospectionModelComplex(modelType.type());
}
public static IntrospectionModel createModelList(final String nodeName, final MapKey modelType) throws AknotException {
return new IntrospectionModelList(nodeName, modelType.type());
}
private IntrospectionModelFactory() {}
}

View File

@ -1,60 +0,0 @@
package org.atriasoft.aknot.pojo;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.IntrospectionModel;
public class IntrospectionModelList extends IntrospectionModel {
final String nodeName;
public IntrospectionModelList(final String nodeName, final Class<?> classType) {
super(classType);
this.nodeName = nodeName;
}
@Override
public Object createObject(final Map<String, Object> properties, final Map<String, List<Object>> nodes, final boolean attributeIndependent) throws AknotException {
return nodes.get(this.getTokenBasicList());
}
@Override
public List<String> getNodeAvaillable() {
if (this.nodeName != null) {
return Arrays.asList(this.nodeName);
}
return null;
}
@Override
public String getTokenBasicList() {
if (this.nodeName == null) {
return STUPID_TOCKEN;
}
return this.nodeName;
}
@Override
public Object getValue(final String propertyName, final String propertyValue) throws AknotException {
return null;
}
@Override
public Object getValueFromText(final String text) throws AknotException {
return new ArrayList<>();
}
@Override
public boolean isList() {
return true;
}
@Override
public String toString(final Object data) {
return null;
}
}

View File

@ -1,346 +0,0 @@
package org.atriasoft.aknot.pojo;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map.Entry;
import org.atriasoft.aknot.StringSerializer;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.InterfaceFactoryAccess;
import org.atriasoft.aknot.model.IntrospectionPropertyGetter;
import org.atriasoft.aknot.model.IntrospectionPropertySetter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public final class IntrospectionProperty {
final static Logger LOGGER = LoggerFactory.getLogger(IntrospectionProperty.class);
// if the element is not managed by us (set at null while not define by a function attribute, parameter ...)
private Boolean managed = null;
// Case sensitive in parsing XML or not (set at null while not define by a function attribute, parameter ...)
private Boolean caseSensitive = null;
// Optional or not (set at null while not define by a function attribute, parameter ...)
private Boolean optionnal = null;
// Attribute or Node (set at null while not define by a function attribute, parameter ...)
private Boolean attribute = null;
// this is a Signal interface
private Boolean signal = null;
private Boolean textMode = null;
// Decription of the element @AknotDescription
private String description = null;
// name of the field or the function before renaming...
private final String beanName;
// names that can take the Node or the attibute
private String[] names = null;
// if organized in sublist (!= null) then the subNode have this value
private String listName = null;
private boolean canBeSetByConstructor = false;
private Class<?> factory = null;
private InterfaceFactoryAccess factoryCreated = null;
private final Class<?> type;
private final Class<?> subType;
// can get the property, if null not gettable ... ==> TODO need to remove this property ???
// First function call
// second field access
IntrospectionPropertyGetter getter = null;
// can get the property, if null not settable (otherwise use the constructor???)
// First constructor call
// second function call
// third field access
IntrospectionPropertySetter setter = null;
public IntrospectionProperty(final String beanName, final Class<?>[] type, final String[] names) {
this.beanName = beanName;
this.type = type[0];
this.subType = type[1];
this.names = names;
}
public boolean canGetValue() {
return this.getter != null;
}
public boolean canSetValue() {
return this.canBeSetByConstructor || this.setter != null;
}
/**
* Create a value adapted to the property type.
* @apiNote generic type is transformed byte -> Byte, int -> Integer ...
* @param value Value to set in the Object
* @throws Exception An error occurred
* @return The object created
*/
public Object createValue(final String value) throws AknotException {
try {
if (StringSerializer.contains(this.type)) {
// TODO This might be a deprecated code ....
return StringSerializer.valueOf(this.type, value);
}
if (this.type.isEnum()) {
} else if ((this.type != List.class) || !StringSerializer.contains(this.subType)) {
throw new AknotException("Can not parse the specific element ... need to introspect and find the 'xxx valueOf(String data);'");
}
final ArrayList<Object> out = new ArrayList<>();
for (final String elem : value.split(";")) {
out.add(StringSerializer.valueOf(this.subType, elem));
}
return out;
} catch (final IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new AknotException("Error in parsing the property value ... " + e.getMessage());
}
}
public String getBeanName() {
return this.beanName;
}
public Class<?> getCompatible(final String name) {
final InterfaceFactoryAccess factoryGenerator = getFactory();
if (factoryGenerator != null) {
if (this.caseSensitive) {
for (final Entry<String, Class<?>> elem : factoryGenerator.getConversionMap().entrySet()) {
if (elem.getKey().contentEquals(name)) {
return elem.getValue();
}
}
} else {
for (final Entry<String, Class<?>> elem : factoryGenerator.getConversionMap().entrySet()) {
if (elem.getKey().equalsIgnoreCase(name)) {
return elem.getValue();
}
}
}
return null;
}
if (this.caseSensitive) {
for (final String elem : this.names) {
if (elem.contentEquals(name)) {
LOGGER.trace(" - '{}' ==> true", elem);
return getType();
}
LOGGER.trace(" - '{}' == false", elem);
}
} else {
for (final String elem : this.names) {
if (elem.equalsIgnoreCase(name)) {
LOGGER.trace(" - '{}' ==> true", elem);
return getType();
}
LOGGER.trace(" - '{}' == false", elem);
}
}
return null;
}
public String getDescription() {
return this.description;
}
public InterfaceFactoryAccess getFactory() {
if (this.factoryCreated == null && this.factory != null) {
try {
this.factoryCreated = (InterfaceFactoryAccess) this.factory.getConstructor().newInstance();
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
// TODO Auto-generated catch block
e.printStackTrace();
this.factoryCreated = null;
this.factory = null;
}
}
return this.factoryCreated;
}
public String getListName() {
return this.listName;
}
/**
* Get list of all names of the property/node (minimal 1 name)
* @return Array of names available
*/
public String[] getNames() {
return this.names;
}
/**
* Get the type of the property (if list ==> need to be get on method otherwise it is an Object...)
* @return Type of the list element.
*/
public Class<?> getSubType() {
return this.subType;
}
/**
* Get basic type of the property
* @return property type detected.
*/
public Class<?> getType() {
return this.type;
}
/**
* Get the value in the object.
* @param object Object that is invoke to get the value.
* @return The generate value of the object
* @throws AknotException in an error occured
*/
public Object getValue(final Object object) throws AknotException {
if (this.getter != null) {
return this.getter.getValue(object);
}
throw new AknotException("Property: " + this.names + " have no getter");
}
public boolean hasFactory() {
return this.factory != null;
}
public Boolean isAttribute() {
return this.attribute;
}
public boolean isCanBeSetByConstructor() {
return this.canBeSetByConstructor;
}
public Boolean isCaseSensitive() {
return this.caseSensitive;
}
/**
* Check if the input name is compatible win an element in the list availlable (respect case sensitive if needed)
* @param name Name to check
* @return true if the element is compatible, false otherwise
*/
public boolean isCompatible(final String name) {
LOGGER.trace("Check compatible : '{}' in {}", name, Arrays.toString(this.names));
final InterfaceFactoryAccess factoryGenerator = getFactory();
if (factoryGenerator != null) {
LOGGER.trace(" ===> Detect factory !!!!");
if (this.caseSensitive) {
for (final Entry<String, Class<?>> elem : factoryGenerator.getConversionMap().entrySet()) {
if (elem.getKey().contentEquals(name)) {
LOGGER.trace(" + '{}' ==> true", elem.getKey());
return true;
}
LOGGER.trace(" + '{}' == false", elem.getKey());
}
} else {
for (final Entry<String, Class<?>> elem : factoryGenerator.getConversionMap().entrySet()) {
if (elem.getKey().equalsIgnoreCase(name)) {
LOGGER.trace(" + '{}' ==> true", elem.getKey());
return true;
}
LOGGER.trace(" + '{}' == false", elem.getKey());
}
}
return false;
}
if (this.caseSensitive) {
for (final String elem : this.names) {
if (elem.contentEquals(name)) {
LOGGER.trace(" - '{}' ==> true", elem);
return true;
}
LOGGER.trace(" - '{}' == false", elem);
}
} else {
for (final String elem : this.names) {
if (elem.equalsIgnoreCase(name)) {
LOGGER.trace(" - '{}' ==> true", elem);
return true;
}
LOGGER.trace(" - '{}' == false", elem);
}
}
return false;
}
public Boolean isManaged() {
return this.managed;
}
public Boolean isOptionnal() {
return this.optionnal;
}
public Boolean isSignal() {
return this.signal;
}
public Boolean isText() {
return this.textMode;
}
public void setAttribute(final Boolean attribute) {
this.attribute = attribute;
}
public void setCanBeSetByConstructor(final boolean canBeSetByConstructor) {
this.canBeSetByConstructor = canBeSetByConstructor;
}
public void setCaseSensitive(final Boolean caseSensitive) {
this.caseSensitive = caseSensitive;
}
public void setDescription(final String description) {
this.description = description;
}
/**
* set the specific string value in the specified object
* @param object Object to add the value
* @param value Value to set in the Object
* @throws Exception An error occurred
*/
public void setExistingValue(final Object object, final Object value) throws AknotException {
if (this.setter != null) {
this.setter.setValue(object, value);
return;
}
throw new AknotException("Property: " + this.names + " have no setter");
}
public void setFactory(final Class<?> factory) {
this.factory = factory;
}
public void setGetter(final IntrospectionPropertyGetter getter) {
this.getter = getter;
}
public void setListName(final String listName) {
this.listName = listName;
}
public void setManaged(final Boolean managed) {
this.managed = managed;
}
public void setNames(final String[] names) {
this.names = names;
}
public void setOptionnal(final Boolean optionnal) {
this.optionnal = optionnal;
}
public void setSetter(final IntrospectionPropertySetter setter) {
this.setter = setter;
}
public void setSignal(final Boolean signal) {
this.signal = signal;
}
public void setTextMode(final Boolean isText) {
this.textMode = isText;
}
}

View File

@ -1,44 +0,0 @@
package org.atriasoft.aknot.pojo;
import java.lang.reflect.Field;
import java.lang.reflect.Modifier;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.IntrospectionPropertyGetter;
import org.atriasoft.aknot.model.IntrospectionPropertySetter;
public class IntrospectionPropertyField implements IntrospectionPropertyGetter, IntrospectionPropertySetter {
private final Field fieldDescription;
private final boolean finalValue;
public IntrospectionPropertyField(final Field fieldDescription) {
this.fieldDescription = fieldDescription;
this.finalValue = Modifier.isFinal(fieldDescription.getModifiers());
}
@Override
public Object getValue(final Object object) throws AknotException {
try {
return this.fieldDescription.get(object);
} catch (IllegalArgumentException | IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new AknotException("Can not set value ... " + e.getMessage());
}
}
@Override
public void setValue(final Object object, final Object value) throws AknotException {
if (this.finalValue) {
throw new AknotException("Can not set value The value is FINAL!!!");
}
try {
this.fieldDescription.set(object, value);
} catch (IllegalArgumentException | IllegalAccessException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new AknotException("Can not set value ... " + e.getMessage());
}
}
}

View File

@ -1,75 +0,0 @@
package org.atriasoft.aknot.pojo;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.IntrospectionPropertyGetter;
public class IntrospectionPropertyMethodGetter implements IntrospectionPropertyGetter {
// private static Class<?>[] getTypefunction(final Method setter, final Method getter) throws Exception {
// Class<?> type = null;
// Class<?> subType = null;
// if (setter == null && getter == null) {
// // impossible case...
// throw new Exception("kjhkhjkj");
// }
// if (getter != null) {
// type = getter.getReturnType();
// if (Enum.class.isAssignableFrom(type)) {
// LOGGER.trace("Find an enum ...");
// } else {
// Type empppe = getter.getGenericReturnType();
// if (empppe instanceof ParameterizedType plopppppp) {
// Type[] realType = plopppppp.getActualTypeArguments();
// if (realType.length > 0) {
// subType = Class.forName(realType[0].getTypeName());
// }
// }
// }
// }
// if (setter != null) {
// if (type != null && setter.getParameters()[0].getType() != type) {
// throw new Exception("The type of the setter ands the type return by the getter are not the same ...");
// }
// type = setter.getParameters()[0].getType();
// if (List.class.isAssignableFrom(type)) {
// Class<?> internalModelClass = null;
// Type[] empppe = setter.getGenericParameterTypes();
// if (empppe.length > 0) {
// if (empppe[0] instanceof ParameterizedType plopppppp) {
// Type[] realType = plopppppp.getActualTypeArguments();
// if (realType.length > 0) {
// LOGGER.warn(" -->> " + realType[0]);
// internalModelClass = Class.forName(realType[0].getTypeName());
// }
// }
// }
// if (getter!=null && internalModelClass != subType) {
// throw new Exception("The type of the setter and the type return by the getter are not the same ...");
// }
// subType = internalModelClass;
// }
// }
// return new Class<?>[] {type, subType};
// }
//
protected Method getter;
public IntrospectionPropertyMethodGetter(final Method getter) throws Exception {
this.getter = getter;
}
@Override
public Object getValue(final Object object) throws AknotException {
if (this.getter == null) {
throw new AknotException("no getter availlable");
}
try {
return this.getter.invoke(object);
} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
e.printStackTrace();
throw new AknotException("Can not set value ... " + e.getMessage());
}
}
}

View File

@ -1,29 +0,0 @@
package org.atriasoft.aknot.pojo;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.model.IntrospectionPropertySetter;
public class IntrospectionPropertyMethodSetter implements IntrospectionPropertySetter {
protected Method setter;
public IntrospectionPropertyMethodSetter(final Method setter) throws Exception {
this.setter = setter;
}
@Override
public void setValue(final Object object, final Object value) throws AknotException {
if (this.setter == null) {
throw new AknotException("no setter availlable");
}
try {
this.setter.invoke(object, value);
} catch (InvocationTargetException | IllegalAccessException | IllegalArgumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw new AknotException("Can not set value ... " + e.getMessage());
}
}
}

16
src/module-info.java Normal file
View File

@ -0,0 +1,16 @@
/** @file
* @author Edouard DUPIN
* @copyright 2021, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
open module org.atriasoft.aknot {
exports org.atriasoft.aknot.reflect;
exports org.atriasoft.aknot.annotation;
exports org.atriasoft.aknot.model;
exports org.atriasoft.aknot.exception;
requires transitive org.atriasoft.etk;
requires transitive io.scenarium.logger;
requires java.base;
}

View File

@ -9,12 +9,12 @@ import java.lang.annotation.Target;
* Marker annotation that force the xml Parser to manage this element (used when the class is mark as @XmldefaultNotManaged).
*
*/
@Target({ ElementType.FIELD, ElementType.CONSTRUCTOR, ElementType.METHOD, ElementType.PARAMETER })
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
@AknotAnnotation
public @interface AknotManaged {
/**
* Set this at false to remove this function or this field form the XML parsing system
* Set this at false to remove this function or this field form the XML parsing system
* @return true if the element is managed.
*/
boolean value() default true;

View File

@ -9,7 +9,7 @@ import java.lang.annotation.Target;
* Marker annotation that can be used to define an other name of the attribute or the Element name.
*
*/
@Target({ ElementType.FIELD, ElementType.TYPE, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PARAMETER })
@Target({ ElementType.FIELD, ElementType.METHOD, ElementType.CONSTRUCTOR, ElementType.PARAMETER })
@Retention(RetentionPolicy.RUNTIME)
@AknotAnnotation
public @interface AknotName {

View File

@ -0,0 +1,81 @@
/** @file
* @author Edouard DUPIN
* @copyright 2021, Edouard DUPIN, all right reserved
* @license MPL v2.0 (see license file)
*/
package org.atriasoft.aknot.internal;
import io.scenarium.logger.LogLevel;
import io.scenarium.logger.Logger;
public class Log {
private static final boolean FORCE_ALL = false;
private static final String LIB_NAME = "exml";
private static final String LIB_NAME_DRAW = Logger.getDrawableName(Log.LIB_NAME);
private static final boolean PRINT_CRITICAL = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.CRITICAL);
private static final boolean PRINT_DEBUG = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.DEBUG);
private static final boolean PRINT_ERROR = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.ERROR);
private static final boolean PRINT_INFO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.INFO);
private static final boolean PRINT_PRINT = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.PRINT);
private static final boolean PRINT_TODO = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.TODO);
private static final boolean PRINT_VERBOSE = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.VERBOSE);
private static final boolean PRINT_WARNING = Logger.getNeedPrint(Log.LIB_NAME, LogLevel.WARNING);
public static void critical(final Exception e, final String data) {
e.printStackTrace();
if (PRINT_CRITICAL || FORCE_ALL) {
Logger.critical(LIB_NAME_DRAW, data + " : " + e.getMessage());
}
}
public static void critical(final String data, final Object... objects) {
if (PRINT_CRITICAL || FORCE_ALL) {
Logger.critical(LIB_NAME_DRAW, data, objects);
}
}
public static void debug(final String data, final Object... objects) {
if (PRINT_DEBUG || FORCE_ALL) {
Logger.debug(LIB_NAME_DRAW, data, objects);
}
}
public static void error(final String data, final Object... objects) {
if (PRINT_ERROR || FORCE_ALL) {
Logger.error(LIB_NAME_DRAW, data, objects);
}
}
public static void info(final String data, final Object... objects) {
if (PRINT_INFO || FORCE_ALL) {
Logger.info(LIB_NAME_DRAW, data, objects);
}
}
public static void print(final String data, final Object... objects) {
if (PRINT_PRINT || FORCE_ALL) {
Logger.print(LIB_NAME_DRAW, data, objects);
}
}
public static void todo(final String data, final Object... objects) {
if (PRINT_TODO || FORCE_ALL) {
Logger.todo(LIB_NAME_DRAW, data, objects);
}
}
public static void verbose(final String data, final Object... objects) {
if (PRINT_VERBOSE || FORCE_ALL) {
Logger.verbose(LIB_NAME_DRAW, data, objects);
}
}
public static void warning(final String data, final Object... objects) {
if (PRINT_WARNING || FORCE_ALL) {
Logger.warning(LIB_NAME_DRAW, data, objects);
}
}
private Log() {}
}

View File

@ -1,6 +1,5 @@
package org.atriasoft.aknot;
package org.atriasoft.aknot.reflect;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
@ -8,22 +7,6 @@ import java.util.List;
import java.util.stream.Collectors;
public class ReflectClass {
// TODO ploàp ...
public class PojoModelData {
public final String name;
public final Class<?> typeData;
public Field field = null;
public Method getMethod = null;
public Method setMethod = null;
public Method isMethod = null;
public PojoModelData(final String name, final Class<?> typeData) {
this.name = name;
this.typeData = typeData;
}
}
// Separate the methods and filer as:
// - XXX GetXxx(); & XXX != boolean
// - void setXxx(XXX elem);

View File

@ -1,8 +1,6 @@
package org.atriasoft.aknot;
package org.atriasoft.aknot.reflect;
import java.lang.annotation.Annotation;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
@ -28,10 +26,9 @@ import org.atriasoft.aknot.annotation.AknotOptional;
import org.atriasoft.aknot.annotation.AknotSignal;
import org.atriasoft.aknot.annotation.AknotText;
import org.atriasoft.aknot.exception.AknotException;
import org.atriasoft.aknot.internal.Log;
public class ReflectTools {
final static Logger LOGGER = LoggerFactory.getLogger(ReflectTools.class);
public static String getDescription(final Class<?> element) throws Exception {
final Annotation[] annotation = element.getDeclaredAnnotationsByType(AknotDescription.class);
if (annotation.length == 0) {
@ -62,10 +59,10 @@ public class ReflectTools {
return tmp;
}
public static String getDescription(final Field element, final String parentValue) throws Exception {
public static String getDescription(final Field element) throws Exception {
final Annotation[] annotation = element.getDeclaredAnnotationsByType(AknotDescription.class);
if (annotation.length == 0) {
return parentValue;
return "";
}
if (annotation.length > 1) {
throw new Exception("Must not have more than 1 element @AknotDescription on " + element.getClass().getCanonicalName());
@ -77,10 +74,10 @@ public class ReflectTools {
return tmp;
}
public static String getDescription(final Method element, final String parentValue) throws Exception {
public static String getDescription(final Method element) throws Exception {
final Annotation[] annotation = element.getDeclaredAnnotationsByType(AknotDescription.class);
if (annotation.length == 0) {
return parentValue;
return "";
}
if (annotation.length > 1) {
throw new Exception("Must not have more than 1 element @AknotDescription on " + element.getClass().getCanonicalName());
@ -246,17 +243,6 @@ public class ReflectTools {
return ((AknotIgnoreUnknown) annotation[0]).value();
}
public static Boolean getIsManaged(final Constructor<?> element, final Boolean parentValue) throws AknotException {
final Annotation[] annotation = element.getDeclaredAnnotationsByType(AknotManaged.class);
if (annotation.length == 0) {
return parentValue;
}
if (annotation.length > 1) {
throw new AknotException("Must not have more than 1 element @ on " + element.getClass().getCanonicalName());
}
return ((AknotManaged) annotation[0]).value();
}
public static Boolean getIsManaged(final Constructor<?> constructor, final Parameter element, final Boolean parentValue) throws AknotException {
final Annotation[] annotation = element.getDeclaredAnnotationsByType(AknotManaged.class);
if (annotation.length == 0) {
@ -397,35 +383,6 @@ public class ReflectTools {
return tmp;
}
public static String[] getNames(final Class<?> element, final String defaultValue) throws Exception {
final Annotation[] annotation = element.getDeclaredAnnotationsByType(AknotName.class);
if (annotation.length == 0) {
if (defaultValue == null) {
return null;
}
return new String[] { defaultValue };
}
if (annotation.length > 1) {
throw new Exception("Must not have more than 1 element @AknotName on " + element.getClass().getCanonicalName());
}
final String[] tmp = ((AknotName) annotation[0]).value();
if (tmp == null) {
throw new Exception("Set null value in decorator @AknotName is not availlable on: " + element.toGenericString());
}
if (tmp.length == 0) {
throw new Exception("Set empty list value in decorator @AknotName is not availlable on: " + element.toGenericString());
}
for (final String elem : tmp) {
if (elem == null) {
throw new Exception("Set null String in list of value in decorator @AknotName is not availlable on: " + element.toGenericString());
}
if (elem.isEmpty()) {
throw new Exception("Set empty String in list of value in decorator @AknotName is not availlable on: " + element.toGenericString());
}
}
return tmp;
}
public static String[] getNames(final Constructor<?> constructor, final Parameter element, final String defaultValue) throws Exception {
final Annotation[] annotation = element.getDeclaredAnnotationsByType(AknotName.class);
if (annotation.length == 0) {
@ -571,9 +528,9 @@ public class ReflectTools {
if (empppe.length > paramId) {
if (empppe[paramId] instanceof final ParameterizedType plopppppp) {
final Type[] realType = plopppppp.getActualTypeArguments();
//LOGGER.info("ppplllppp: " + realType.length);
//Log.info("ppplllppp: " + realType.length);
if (realType.length > 0) {
LOGGER.trace(" -->> {}", realType[0]);
Log.verbose(" -->> " + realType[0]);
internalModelClass = Class.forName(realType[0].getTypeName());
}
}
@ -595,7 +552,7 @@ public class ReflectTools {
if (empppe[0] instanceof final ParameterizedType plopppppp) {
final Type[] realType = plopppppp.getActualTypeArguments();
if (realType.length > 0) {
LOGGER.trace(" -->> {}", realType[0]);
Log.verbose(" -->> " + realType[0]);
internalModelClass = Class.forName(realType[0].getTypeName());
}
}

View File

@ -5,19 +5,17 @@
*/
package test.atriasoft.aknot;
import org.atriasoft.aknot.internal.Log;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ExmlTestElement {
final static Logger LOGGER = LoggerFactory.getLogger(ExmlTestElement.class);
@BeforeAll
public static void beforeClass() {
LOGGER.trace("----------------------------------------------------------------");
Log.verbose("----------------------------------------------------------------");
}
@Test
public void append() {
/*
@ -31,7 +29,7 @@ public class ExmlTestElement {
Assertions.fail("Should Not have thrown an exception");
}
*/
//Assertions.assertEquals(156, 1);
Assertions.assertEquals(156, 1);
}
}