Skip to content

Commit 11189bb

Browse files
committed
Refactoring
1 parent 7c0585f commit 11189bb

File tree

5 files changed

+29
-29
lines changed

5 files changed

+29
-29
lines changed

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/loader/instantiator/PropertyInstantiator.java

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -66,41 +66,41 @@ public Property apply(final Resource property) {
6666
property.getModel().contains(property, RDF.type, SammNs.SAMM.AbstractProperty());
6767

6868
final MetaModelBaseAttributes metaModelBaseAttributes = property.isAnon()
69-
? buildBaseAttributes(extendsResource.orElse(property))
70-
: buildBaseAttributes(property);
71-
final DefaultPropertyWrapper defaultPropertyWrapper = new DefaultPropertyWrapper(metaModelBaseAttributes);
69+
? buildBaseAttributes( extendsResource.orElse( property ) )
70+
: buildBaseAttributes( property );
71+
final DefaultPropertyWrapper defaultPropertyWrapper = new DefaultPropertyWrapper( metaModelBaseAttributes );
7272

73-
if (resourcePropertyMap.containsKey(property)) {
74-
return resourcePropertyMap.get(property);
73+
if ( resourcePropertyMap.containsKey( property )) {
74+
return resourcePropertyMap.get( property );
7575
}
76-
resourcePropertyMap.put(property, defaultPropertyWrapper);
76+
resourcePropertyMap.put( property, defaultPropertyWrapper );
7777

7878
final DefaultProperty defProperty;
79-
if (isAbstract) {
80-
defProperty = new DefaultProperty(metaModelBaseAttributes, Optional.of(fallbackCharacteristic),
81-
Optional.empty(), isOptional, isNotInPayload, payloadName, isAbstract, extends_);
79+
if ( isAbstract ) {
80+
defProperty = new DefaultProperty( metaModelBaseAttributes, Optional.of( fallbackCharacteristic ),
81+
Optional.empty(), isOptional, isNotInPayload, payloadName, isAbstract, extends_ );
8282
} else {
83-
final Resource characteristicResource = attributeValue(property, SammNs.SAMM.characteristic()).getResource();
84-
final Characteristic characteristic = modelElementFactory.create(Characteristic.class, characteristicResource);
83+
final Resource characteristicResource = attributeValue( property, SammNs.SAMM.characteristic() ).getResource();
84+
final Characteristic characteristic = modelElementFactory.create( Characteristic.class, characteristicResource );
8585

86-
final Optional<Object> exampleValue = optionalAttributeValue(property, SammNs.SAMM.exampleValue())
87-
.flatMap(statement -> {
86+
final Optional<Object> exampleValue = optionalAttributeValue( property, SammNs.SAMM.exampleValue() )
87+
.flatMap( statement -> {
8888
RDFNode node = statement.getObject();
8989
return characteristic.getDataType()
90-
.map(type -> {
91-
if (!type.is(Scalar.class)) {
92-
throw new AspectLoadingException("Type of example value on Property " + property + " has incorrect type");
90+
.map( type -> {
91+
if ( !type.is( Scalar.class ) ) {
92+
throw new AspectLoadingException( "Type of example value on Property " + property + " has incorrect type" );
9393
}
94-
return type.as(Scalar.class);
94+
return type.as( Scalar.class );
9595
})
96-
.map(type -> buildValue(node, Optional.of(property), type)); // <-- используем buildValue
96+
.map( type -> buildValue( node, Optional.of( property ), type ) );
9797
});
9898

99-
defProperty = new DefaultProperty(metaModelBaseAttributes, Optional.of(characteristic),
100-
exampleValue, isOptional, isNotInPayload, payloadName, isAbstract, extends_);
99+
defProperty = new DefaultProperty( metaModelBaseAttributes, Optional.of( characteristic ),
100+
exampleValue, isOptional, isNotInPayload, payloadName, isAbstract, extends_ );
101101
}
102102

103-
defaultPropertyWrapper.setProperty(defProperty);
103+
defaultPropertyWrapper.setProperty( defProperty );
104104
return defaultPropertyWrapper;
105105
}
106106

core/esmf-aspect-meta-model-java/src/main/java/org/eclipse/esmf/aspectmodel/serializer/RdfModelCreatorVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -647,8 +647,8 @@ public ElementModel visitProperty( final Property property, final ModelElement c
647647
model.add( serializeDescriptions( resource, property ) );
648648

649649
property.getExampleValue().ifPresent( exampleValue -> {
650-
if ( exampleValue instanceof Value ) {
651-
final ElementModel exampleValueElementModel = ((Value) exampleValue).accept( this, property );
650+
if ( exampleValue instanceof Value value ) {
651+
final ElementModel exampleValueElementModel = ( value ).accept( this, property );
652652
model.add( exampleValueElementModel.model() );
653653
exampleValueElementModel.focusElement().ifPresent( exampleValueNode ->
654654
model.add( resource, SammNs.SAMM.exampleValue(), exampleValueNode ) );

core/esmf-aspect-meta-model-java/src/test/resources/samm_2_0_0/invalid_aspect_urn_prefix.ttl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
#
1010
# SPDX-License-Identifier: MPL-2.0
1111

12-
@prefix samm: <urn:foo:org.eclipse.esmf.samm:meta-model:2.1.0#> .
12+
@prefix samm: <urn:foo:org.eclipse.esmf.samm:meta-model:2.0.0#> .
1313

1414
<urn:samm:org.eclipse.esmf.samm:aspect-model:TestAspect:1.1.0> a samm:Aspect ;
1515
samm:preferredName "Test Aspect"@en ;

core/esmf-aspect-model-document-generators/src/main/java/org/eclipse/esmf/aspectmodel/generator/json/AspectModelJsonPayloadGenerator.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ private Type getDataType( final Characteristic characteristic ) {
452452
private Object generateExampleValue( final Characteristic characteristic ) {
453453
final Type dataType = getDataType( characteristic );
454454

455-
if ( !(dataType.is( Scalar.class )) ) {
455+
if ( !( dataType.is( Scalar.class ) ) ) {
456456
throw new IllegalArgumentException( "Example values can only be generated for scalar types." );
457457
}
458458

@@ -630,7 +630,7 @@ private Number generateForNumericTypeInRange( final java.lang.reflect.Type value
630630

631631
// narrowing conversion from BigDecimal to double
632632
private double safelyNarrowDown( final Number bound ) {
633-
if ( !(BigDecimal.class.equals( bound.getClass() )) ) {
633+
if ( !( BigDecimal.class.equals( bound.getClass() ) ) ) {
634634
return bound.doubleValue();
635635
}
636636

@@ -639,7 +639,7 @@ private double safelyNarrowDown( final Number bound ) {
639639
// Example: xsd:unsignedLong has a max. value of 18446744073709551615; when converting it to double
640640
// it will get represented as 1.8446744073709552E16, thereby exceeding the upper bound.
641641
// Therefore we need to take care of always rounding down when narrowing to double.
642-
final BigDecimal narrowed = ((BigDecimal) bound).round( new MathContext( 15, RoundingMode.DOWN ) );
642+
final BigDecimal narrowed = ( (BigDecimal) bound ).round( new MathContext( 15, RoundingMode.DOWN ) );
643643
return narrowed.doubleValue();
644644
}
645645

core/esmf-aspect-model-java-generator/src/main/java/org/eclipse/esmf/aspectmodel/java/metamodel/StaticMetaModelVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -526,8 +526,8 @@ private <T> String getOptionalStaticDeclarationValue( final Type type, final Opt
526526
return "Optional.empty()";
527527
}
528528

529-
if ( optionalValue.get() instanceof ScalarValue ) {
530-
return "Optional.of(" + ((ScalarValue) optionalValue.get()).accept( this, context ) + ")";
529+
if ( optionalValue.get() instanceof ScalarValue scalarValue ) {
530+
return "Optional.of(" + ( scalarValue ).accept( this, context ) + ")";
531531
}
532532

533533
context.getCodeGenerationConfig().importTracker().importExplicit( AspectModelJavaUtil.getDataTypeClass( type ) );

0 commit comments

Comments
 (0)