From 0c37a013397f24e9ea7c314e9c7a270d4505ff91 Mon Sep 17 00:00:00 2001 From: Luca Frosini Date: Tue, 4 Jun 2024 16:56:32 +0200 Subject: [PATCH] Fixing code --- .../types/impl/properties/PropertyDefinitionImpl.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java b/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java index e13be75..a56babf 100644 --- a/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java +++ b/src/main/java/org/gcube/informationsystem/types/impl/properties/PropertyDefinitionImpl.java @@ -83,9 +83,11 @@ public final class PropertyDefinitionImpl extends PropertyBasicInfoImpl implemen } public static Object evaluateDefaultValue(BaseType baseType, String defaultValueAsString) { - if(defaultValueAsString.compareTo("null")==0) { + + if(defaultValueAsString==null || defaultValueAsString.compareTo("null")==0) { return null; } + if(defaultValueAsString!=null) { switch (baseType) { case BOOLEAN: @@ -135,11 +137,12 @@ public final class PropertyDefinitionImpl extends PropertyBasicInfoImpl implemen return null; default: - return null; + break; } } return null; + } public PropertyDefinitionImpl(ISProperty propertyAnnotation, Method method) { @@ -158,7 +161,8 @@ public final class PropertyDefinitionImpl extends PropertyBasicInfoImpl implemen this.propertyTypeName = new PropertyTypeName(method); this.defaultValue = propertyAnnotation.defaultValue(); - evaluateDefaultValue(propertyTypeName.getBaseType(), defaultValue); + // The default value is evaluated to test if compliant with the declared type + PropertyDefinitionImpl.evaluateDefaultValue(propertyTypeName.getBaseType(), defaultValue); Class clz = method.getReturnType(); logger.trace("Return Type for method {} is {}", method, clz);