[core] RuleSetWriter - write property value as attribute
This commit is contained in:
parent
802decbbcf
commit
df1a6797c6
@ -286,7 +286,7 @@ public class RuleSetWriter {
|
||||
if (isPropertyDefinition) {
|
||||
propertiesElement.appendChild(createPropertyDefinitionElementBR(descriptor, typeId));
|
||||
} else {
|
||||
propertiesElement.appendChild(propertyElementWithValue(propertySource, descriptor));
|
||||
propertiesElement.appendChild(propertyElementWithValueAttribute(propertySource, descriptor));
|
||||
}
|
||||
}
|
||||
|
||||
@ -294,8 +294,14 @@ public class RuleSetWriter {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
private <T> Element propertyElementWithValue(PropertySource propertySource, PropertyDescriptor<T> descriptor) {
|
||||
return createPropertyValueElement(descriptor, propertySource.getProperty(descriptor));
|
||||
private <T> Element propertyElementWithValueAttribute(PropertySource propertySource, PropertyDescriptor<T> propertyDescriptor) {
|
||||
Element element = document.createElementNS(RULESET_2_0_0_NS_URI, "property");
|
||||
SchemaConstants.NAME.setOn(element, propertyDescriptor.name());
|
||||
|
||||
PropertySerializer<T> xmlStrategy = propertyDescriptor.serializer();
|
||||
T value = propertySource.getProperty(propertyDescriptor);
|
||||
SchemaConstants.PROPERTY_VALUE.setOn(element, xmlStrategy.toString(value));
|
||||
return element;
|
||||
}
|
||||
|
||||
private <T> Element createPropertyValueElement(PropertyDescriptor<T> propertyDescriptor, T value) {
|
||||
|
@ -174,6 +174,6 @@ class RuleSetWriterTest extends RulesetFactoryTestBase {
|
||||
assertThat(written, not(containsString("min=\"")));
|
||||
assertThat(written, not(containsString("max=\"")));
|
||||
assertThat(written, not(containsString("type=\"")));
|
||||
assertThat(written, containsString("42"));
|
||||
assertThat(written, containsString("value=\"42\""));
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user