Skip to content

Commit 28a92a5

Browse files
Fix further code smells
1 parent 1884d91 commit 28a92a5

File tree

3 files changed

+7
-9
lines changed

3 files changed

+7
-9
lines changed

core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAASVisitor.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -576,11 +576,11 @@ private Optional<SubmodelElement> handleEitherField( final String field, final C
576576
final var fieldProperty = createProperty( eitherProperty.getMetaModelVersion(), field, fieldCharacteristic );
577577
context.setProperty( fieldProperty );
578578
if ( context.getRawPropertyValue().isPresent() ) {
579-
result = Optional.ofNullable( decideOnMapping( fieldCharacteristic.getDataType().get(), context.getProperty(), context ) );
579+
result = fieldCharacteristic.getDataType().map( dataType -> decideOnMapping( dataType, context.getProperty(), context ) );
580580
}
581581
context.getPropertyResult();
582582
} else {
583-
result = Optional.ofNullable( decideOnMapping( fieldCharacteristic.getDataType().get(), context.getProperty(), context ) );
583+
result = fieldCharacteristic.getDataType().map( dataType -> decideOnMapping( dataType, context.getProperty(), context ) );
584584
}
585585

586586
return result;

core/esmf-aspect-model-aas-generator/src/main/java/org/eclipse/esmf/aspectmodel/aas/Context.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,9 @@
2727
import org.eclipse.digitaltwin.aas4j.v3.model.ModellingKind;
2828
import org.eclipse.digitaltwin.aas4j.v3.model.Submodel;
2929
import org.eclipse.digitaltwin.aas4j.v3.model.SubmodelElement;
30+
import org.eclipse.esmf.metamodel.Property;
3031

3132
import com.fasterxml.jackson.databind.JsonNode;
32-
import org.eclipse.esmf.metamodel.Property;
3333

3434

3535
/**
@@ -38,12 +38,12 @@
3838
public class Context {
3939

4040
Environment environment;
41-
Submodel submodel;
41+
final Submodel submodel;
4242
Property property;
4343
SubmodelElement propertyResult;
44-
List<Property> propertyPath = new ArrayList<>();
44+
final List<Property> propertyPath = new ArrayList<>();
4545
JsonNode aspectData;
46-
Map<Property, Integer> indices = new HashMap<>();
46+
final Map<Property, Integer> indices = new HashMap<>();
4747

4848
public Context( final Environment environment, final Submodel ofInterest ) {
4949
this.environment = environment;

core/esmf-aspect-model-aas-generator/src/test/java/org/eclipse/esmf/aspectmodel/aas/AspectModelAASGeneratorTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -365,9 +365,7 @@ private Environment getAssetAdministrationShellFromAspectWithData( final TestAsp
365365
final JsonNode aspectData = loadPayload( testAspect );
366366
final ByteArrayOutputStream out = generator.generateXmlOutput( Map.of( aspect, aspectData ) );
367367
final var data = out.toByteArray();
368-
final var result = loadAASX( data, testAspect );
369-
//new AasXmlValidator().validateXml( data );
370-
return result;
368+
return loadAASX( data, testAspect );
371369
}
372370

373371
private ByteArrayOutputStream getByteArrayOutputStreamFromAspect( final TestAspect testAspect )

0 commit comments

Comments
 (0)