AbstractSimpleProperty specifiedTypeProperty;
if (propertyValue == null) {
// Search in properties to erase
Iterator<AbstractField> it = content.getAllProperties().iterator();
AbstractField tmp;
while (it.hasNext()) {
tmp = it.next();
if (tmp.getQualifiedName().equals(qualifiedName)) {
content.removeProperty(tmp);
return;
}
}
} else {
try {
propertyConstructor = type.getConstructor(propertyArgsClass);
specifiedTypeProperty = (AbstractSimpleProperty) propertyConstructor
.newInstance(propertyArgs);
} catch (Exception e) {
throw new IllegalArgumentException(
"Failed to create property with the specified type given in parameters",
e);
}
// attribute placement for simple property has been removed
// Search in properties to erase
Iterator<AbstractField> it = content.getAllProperties().iterator();
AbstractField tmp;
while (it.hasNext()) {
tmp = it.next();
if (tmp.getQualifiedName().equals(qualifiedName)) {
content.removeProperty(tmp);
content.addProperty(specifiedTypeProperty);
return;
}
}