diff --git a/core/esmf-aspect-model-java-generator/pom.xml b/core/esmf-aspect-model-java-generator/pom.xml index 43575a63a..1c8c3d921 100644 --- a/core/esmf-aspect-model-java-generator/pom.xml +++ b/core/esmf-aspect-model-java-generator/pom.xml @@ -57,6 +57,10 @@ record-builder-processor provided + + org.apache.jena + jena-core + diff --git a/core/esmf-aspect-model-java-generator/src/main/java/org/eclipse/esmf/aspectmodel/java/AspectModelJavaUtil.java b/core/esmf-aspect-model-java-generator/src/main/java/org/eclipse/esmf/aspectmodel/java/AspectModelJavaUtil.java index 03d7f2429..beee67eaf 100644 --- a/core/esmf-aspect-model-java-generator/src/main/java/org/eclipse/esmf/aspectmodel/java/AspectModelJavaUtil.java +++ b/core/esmf-aspect-model-java-generator/src/main/java/org/eclipse/esmf/aspectmodel/java/AspectModelJavaUtil.java @@ -622,4 +622,13 @@ public static AbstractEntity castToAbstractEntity( final ComplexType complexType public static Quantifiable castToQuantifiable( final Characteristic characteristic ) { return (Quantifiable) characteristic; } + + public static String getterName( final Property property ) { + final boolean isBooleanType = !property.isOptional() + && property.getDataType() + .filter( Type::isScalar ) + .map( type -> XSD.xboolean.getURI().equals( type.getUrn() ) ) + .orElse( false ); + return (isBooleanType ? "is" : "get") + StringUtils.capitalize( property.getPayloadName() ); + } } diff --git a/core/esmf-aspect-model-java-generator/src/main/resources/java-pojo-getter-lib.vm b/core/esmf-aspect-model-java-generator/src/main/resources/java-pojo-getter-lib.vm index 411779884..0205ad136 100644 --- a/core/esmf-aspect-model-java-generator/src/main/resources/java-pojo-getter-lib.vm +++ b/core/esmf-aspect-model-java-generator/src/main/resources/java-pojo-getter-lib.vm @@ -10,26 +10,23 @@ ~ ~ SPDX-License-Identifier: MPL-2.0 *# -#macro( methodName ) - #if( $property.getDataType().isPresent() ) - #set( $type = $property.dataType.get() ) - #if( $type.isScalar() && $type.getUrn().equals( $XSD.xboolean.getURI() ) )is#{else}get#{end} - #{else}get#{end}${StringUtils.capitalize( $property.getPayloadName() )}#{end} #macro( javaPojoGetter $property $propertyIndex ) +#set( $methodName = $util.getterName( $property ) ) + /** * Returns $property.getPreferredName( $localeEn ) * * @return {@link #$property.getPayloadName()} */ #if( $property.isAbstract() ) - public abstract T${propertyIndex} #methodName()(); + public abstract T${propertyIndex} $methodName(); #else #set( $propertyType = $util.getPropertyType( $property, false, $codeGenerationConfig ) ) #if( $property.getExtends().isPresent() )@Override #end #if( $util.isPropertyNotInPayload( $property, $codeGenerationConfig ) )@JsonIgnore #end -public $propertyType #methodName()() { +public $propertyType $methodName() { return this.$property.getPayloadName(); } #end