[DEV] continue integration properties

This commit is contained in:
Edouard DUPIN 2021-12-22 00:41:12 +01:00
parent ce7b909cb0
commit 24d9099a85
3 changed files with 809 additions and 788 deletions

File diff suppressed because it is too large Load Diff

View File

@ -21,79 +21,6 @@ public class IntrospectionObject {
this.modelInterface = dataInterface; this.modelInterface = dataInterface;
} }
public Object getData() {
return this.data;
}
public IntrospectionModel getModelIntrospection() {
return this.modelInterface;
}
public void putProperty(final String propertyName, final Object propertyValue) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(propertyName);
if (this.properties.containsKey(beanName)) {
throw new ExmlBuilderException("Property have multiple values ==> impossible case; A Node must contain only 1 attibutes");
}
this.properties.put(beanName, propertyValue);
}
public boolean isSubNodeOrPropertyExist(final String nodeName) {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
return false;
}
return true;
}
/**
* Detect a subNode, and ask the type of the node at the parent Class
* @param nodeName Name of the node
* @return Class of the node to create
*/
public Class<?> getTypeOfSubNode(final String nodeName) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfSubNode(beanName);
}
public Class<?> getTypeOfSubNodeSubType(final String nodeName) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfSubNodeList(beanName);
}
public String getTreeNameOfSubNode(final String nodeName) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTreeNameOfSubNode(beanName);
}
public Class<?> getTypeOfProperty(final String nodeName) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfProperty(beanName);
}
public Class<?> getTypeOfSubProperty(final String nodeName) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfSubProperty(beanName);
}
public void setText(final String text) throws ExmlBuilderException {
if (this.data != null) {
throw new ExmlBuilderException("Can not set multiple text value in a single NODE ...");
}
this.data = this.modelInterface.getValueFromText(text);
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public void addObject(final String nodeName, final Object value) throws ExmlException { public void addObject(final String nodeName, final Object value) throws ExmlException {
if (value == null) { if (value == null) {
@ -148,10 +75,87 @@ public class IntrospectionObject {
// nothing to do ... ==> element already created // nothing to do ... ==> element already created
return; return;
} }
Log.info("Create the element for the Specific node ... type = " + this.modelInterface.getClassType().getCanonicalName() + (this.modelInterface.isArray()?"[array]":"") + (this.modelInterface.isList()?"[List]":"")); Log.debug("Create the element for the Specific node ... type = " + this.modelInterface.getClassType().getCanonicalName() + (this.modelInterface.isArray() ? "[array]" : "")
Log.info(" Properties : " + this.properties.keySet()); + (this.modelInterface.isList() ? "[List]" : ""));
Log.info(" Nodes : " + this.nodes.keySet()); Log.debug(" Properties : " + this.properties.keySet());
Log.debug(" Nodes : " + this.nodes.keySet());
this.data = this.modelInterface.createObject(this.properties, this.nodes); this.data = this.modelInterface.createObject(this.properties, this.nodes);
} }
public Object getData() {
return this.data;
}
public IntrospectionModel getModelIntrospection() {
return this.modelInterface;
}
public String getTreeNameOfSubNode(final String nodeName) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTreeNameOfSubNode(beanName);
}
public Class<?> getTypeOfProperty(final String nodeName) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfProperty(beanName);
}
/**
* Detect a subNode, and ask the type of the node at the parent Class
* @param nodeName Name of the node
* @return Class of the node to create
*/
public Class<?> getTypeOfSubNode(final String nodeName) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfSubNode(beanName);
}
public Class<?> getTypeOfSubNodeSubType(final String nodeName) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfSubNodeList(beanName);
}
public Class<?> getTypeOfSubProperty(final String nodeName) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
throw new ExmlNodeDoesNotExist("The node '" + nodeName + "' Does not exist...");
}
return this.modelInterface.getTypeOfSubProperty(beanName);
}
public boolean isSubNodeOrPropertyExist(final String nodeName) {
final String beanName = this.modelInterface.getBeanName(nodeName);
if (beanName == null) {
return false;
}
return true;
}
public void putProperty(final String propertyName, final Object propertyValue) throws ExmlException {
final String beanName = this.modelInterface.getBeanName(propertyName);
if (this.properties.containsKey(beanName)) {
throw new ExmlBuilderException("Property have multiple values ==> impossible case; A Node must contain only 1 attibutes");
}
this.properties.put(beanName, propertyValue);
}
public void setText(final String text) throws ExmlBuilderException {
if (this.data != null) {
throw new ExmlBuilderException("Can not set multiple text value in a single NODE ...");
}
this.data = this.modelInterface.getValueFromText(text);
}
} }

View File

@ -38,17 +38,6 @@ public final class IntrospectionProperty {
// third field access // third field access
IntrospectionPropertySetter setter = null; IntrospectionPropertySetter setter = null;
public String getListName() {
return this.listName;
}
public boolean isCanBeSetByConstructor() {
return this.canBeSetByConstructor;
}
public void setCanBeSetByConstructor(final boolean canBeSetByConstructor) {
this.canBeSetByConstructor = canBeSetByConstructor;
}
public IntrospectionProperty(final String beanName, final Class<?>[] type, final String[] names) { public IntrospectionProperty(final String beanName, final Class<?>[] type, final String[] names) {
this.beanName = beanName; this.beanName = beanName;
this.type = type[0]; this.type = type[0];
@ -56,13 +45,6 @@ public final class IntrospectionProperty {
this.names = names; this.names = names;
} }
public void setSetter(final IntrospectionPropertySetter setter) {
this.setter = setter;
}
public void setGetter(final IntrospectionPropertyGetter getter) {
this.getter = getter;
}
public boolean canGetValue() { public boolean canGetValue() {
return this.getter != null; return this.getter != null;
} }
@ -71,80 +53,6 @@ public final class IntrospectionProperty {
return this.canBeSetByConstructor || this.setter != null; return this.canBeSetByConstructor || this.setter != null;
} }
/**
* Get list of all names of the property/node (minimal 1 name)
* @return Array of names available
*/
public String[] getNames() {
return this.names;
}
/**
* Get basic type of the property
* @return property type detected.
*/
public Class<?> getType() {
return this.type;
}
/**
* 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 the value in the object.
* @param object Object that is invoke to get the value.
* @return The generate value of the object
* @throws ExmlBuilderException in an error occured
*/
public Object getValue(final Object object) throws ExmlBuilderException {
if (this.getter != null) {
return this.getter.getValue(object);
}
throw new ExmlBuilderException("Property: " + this.names + " have no getter");
}
/**
* 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) {
Log.warning("Check compatible : '" + name + "' in " + Arrays.toString(this.names));
if (this.caseSensitive) {
for (final String elem : this.names) {
if (elem.contentEquals(name)) {
Log.warning(" - '" + elem + "' ==> true");
return true;
}
Log.warning(" - '" + elem + "' == false");
}
} else {
for (final String elem : this.names) {
if (elem.equalsIgnoreCase(name)) {
Log.warning(" - '" + elem + "' ==> true");
return true;
}
Log.warning(" - '" + elem + "' == false");
}
}
return false;
}
/**
* 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 ExmlBuilderException {
if (this.setter != null) {
this.setter.setValue(object, value);
return;
}
throw new ExmlBuilderException("Property: " + this.names + " have no setter");
}
/** /**
* Create a value adapted to the property type. * Create a value adapted to the property type.
* @apiNote generic type is transformed byte -> Byte, int -> Integer ... * @apiNote generic type is transformed byte -> Byte, int -> Integer ...
@ -175,38 +83,146 @@ public final class IntrospectionProperty {
} }
} }
public Boolean isCaseSensitive() {
return this.caseSensitive;
}
public void setCaseSensitive(final Boolean caseSensitive) {
this.caseSensitive = caseSensitive;
}
public Boolean isOptionnal() {
return this.optionnal;
}
public void setOptionnal(final Boolean optionnal) {
this.optionnal = optionnal;
}
public Boolean isAttribute() {
return this.attribute;
}
public void setAttribute(final Boolean attribute) {
this.attribute = attribute;
}
public String getBeanName() { public String getBeanName() {
return this.beanName; return this.beanName;
} }
public void setNames(final String[] names) {
this.names = names; public String getListName() {
return this.listName;
} }
public void setListName(final String listName) {
this.listName = 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 ExmlBuilderException in an error occured
*/
public Object getValue(final Object object) throws ExmlBuilderException {
if (this.getter != null) {
return this.getter.getValue(object);
}
throw new ExmlBuilderException("Property: " + this.names + " have no getter");
}
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) {
Log.verbose("Check compatible : '" + name + "' in " + Arrays.toString(this.names));
if (this.caseSensitive) {
for (final String elem : this.names) {
if (elem.contentEquals(name)) {
Log.verbose(" - '" + elem + "' ==> true");
return true;
}
Log.verbose(" - '" + elem + "' == false");
}
} else {
for (final String elem : this.names) {
if (elem.equalsIgnoreCase(name)) {
Log.verbose(" - '" + elem + "' ==> true");
return true;
}
Log.verbose(" - '" + elem + "' == false");
}
}
return false;
}
public Boolean isManaged() { public Boolean isManaged() {
return this.managed; return this.managed;
} }
public Boolean isOptionnal() {
return this.optionnal;
}
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;
}
/**
* 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 ExmlBuilderException {
if (this.setter != null) {
this.setter.setValue(object, value);
return;
}
throw new ExmlBuilderException("Property: " + this.names + " have no setter");
}
public void setGetter(final IntrospectionPropertyGetter getter) {
this.getter = getter;
}
public void setListName(final String listName) {
this.listName = listName;
}
public void setManaged(final Boolean managed) { public void setManaged(final Boolean managed) {
this.managed = 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;
}
} }