TypeDefinition.getDefaultValue() is returning an optional, which
results in it always being non-null. Fix the check for nullness
and make sure we use the correct value.
Change-Id: Id5aba6cd215d4e19f8b583a81e5599daa9bbe12d
Signed-off-by: Magic_J <panda.magic.j@gmail.com>
Signed-off-by: Robert Varga <robert.varga@pantheon.tech>
private String processTypeDef(final TypeDefinition<?> leafTypeDef, final DataSchemaNode node,
final ObjectNode property, final SchemaContext schemaContext) {
final String jsonType;
- if (leafTypeDef.getDefaultValue() == null) {
+ final Object defValue = leafTypeDef.getDefaultValue().orElse(null);
+ if (defValue == null) {
if (leafTypeDef instanceof BinaryTypeDefinition) {
jsonType = processBinaryType(property);
}
} else {
- jsonType = String.valueOf(leafTypeDef.getDefaultValue());
+ jsonType = String.valueOf(defValue);
}
putIfNonNull(property, TYPE_KEY, jsonType);
return jsonType;