Skip to content

Commit c149458

Browse files
committed
Fix code style
1 parent e0a90b7 commit c149458

File tree

2 files changed

+49
-52
lines changed

2 files changed

+49
-52
lines changed

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

Lines changed: 29 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ ImmutableMap.<Resource, DataTypeDefXSD> builder()
162162
.put( XSD.xint, DataTypeDefXSD.INT )
163163
.put( XSD.integer, DataTypeDefXSD.INTEGER )
164164
.put( XSD.xlong, DataTypeDefXSD.LONG )
165-
.put( XSD.negativeInteger, DataTypeDefXSD.NEGATIVE_INTEGER)
165+
.put( XSD.negativeInteger, DataTypeDefXSD.NEGATIVE_INTEGER )
166166
.put( XSD.nonNegativeInteger, DataTypeDefXSD.NON_NEGATIVE_INTEGER )
167167
.put( XSD.positiveInteger, DataTypeDefXSD.POSITIVE_INTEGER )
168168
.put( XSD.xshort, DataTypeDefXSD.SHORT )
@@ -193,8 +193,8 @@ public Environment visitAspect( final Aspect aspect, Context context ) {
193193
if ( context == null ) {
194194
final Submodel submodel = new DefaultSubmodel.Builder().build();
195195
Environment environment = new DefaultEnvironment.Builder().submodels( Collections.singletonList( submodel ) ).build();
196-
context = new Context(environment, submodel );
197-
context.setEnvironment(environment);
196+
context = new Context( environment, submodel );
197+
context.setEnvironment( environment );
198198
}
199199

200200
final Submodel submodel = context.getSubmodel();
@@ -210,7 +210,7 @@ public Environment visitAspect( final Aspect aspect, Context context ) {
210210
final AssetAdministrationShell administrationShell =
211211
new DefaultAssetAdministrationShell.Builder()
212212
.idShort( ID_PREFIX + ADMIN_SHELL_NAME )
213-
.description( createLangStringTextType( "en", ADMIN_SHELL_NAME) )
213+
.description( createLangStringTextType( "en", ADMIN_SHELL_NAME ) )
214214
.id( ADMIN_SHELL_NAME )
215215
.administration( new DefaultAdministrativeInformation.Builder().build() )
216216
.assetInformation( new DefaultAssetInformation.Builder().assetKind( AssetKind.INSTANCE ).build() )
@@ -234,8 +234,8 @@ private List<SubmodelElement> visitOperations(
234234
private List<SubmodelElement> visitProperties(
235235
final List<Property> elements, final Context context ) {
236236
return elements.stream().map( i -> mapText( i, context ) )
237-
.filter(Optional::isPresent)
238-
.map(Optional::get)
237+
.filter( Optional::isPresent )
238+
.map( Optional::get )
239239
.collect( Collectors.toList() );
240240
}
241241

@@ -253,7 +253,8 @@ private Optional<SubmodelElement> mapText( final Property property, final Contex
253253
property.getAspectModelUrn().map( AspectModelUrn::toString ).orElse( "(unknown)" ) ) );
254254
return defaultResultForProperty;
255255
} else {
256-
LOG.error( String.format( "Having a recursive property: %s which is not optional is not valid. Check the model. Property will be excluded from AAS mapping.",
256+
LOG.error( String.format(
257+
"Having a recursive property: %s which is not optional is not valid. Check the model. Property will be excluded from AAS mapping.",
257258
property.getAspectModelUrn().map( AspectModelUrn::toString ).orElse( "(unknown)" ) ) );
258259
}
259260
return defaultResultForProperty;
@@ -308,17 +309,17 @@ private SubmodelElementCollection mapToAasSubModelElementCollection( final Entit
308309
private org.eclipse.digitaltwin.aas4j.v3.model.Property mapToAasProperty( final Property property ) {
309310
return new DefaultProperty.Builder()
310311
.idShort( ID_PREFIX + property.getName() )
311-
.valueType( mapAASXSDataType( property.getCharacteristic().flatMap( Characteristic::getDataType ).map( this::mapType ).orElse( UNKNOWN_TYPE ) ) )
312+
.valueType( mapAASXSDataType( property.getCharacteristic().flatMap( Characteristic::getDataType ).map( this::mapType ).orElse( UNKNOWN_TYPE ) ) )
312313
.displayName( mapName( property.getPreferredNames() ) )
313314
.value( property.getExampleValue().map( i -> i.getValue().toString() ).orElse( UNKNOWN_EXAMPLE ) )
314315
.description( mapText( property.getDescriptions() ) )
315316
.semanticID( buildReferenceToConceptDescription( property ) ) // link to the conceptDescription containing the details for the Characteristic
316-
.supplementalSemanticIds( buildReferencesForSeeElements(property.getSee()) )
317+
.supplementalSemanticIds( buildReferencesForSeeElements( property.getSee() ) )
317318
.build();
318319
}
319320

320321
private String extractIdentifier( final NamedElement element ) {
321-
return determineIdentifierFor( element );
322+
return determineIdentifierFor( element );
322323
}
323324

324325
private String mapType( final Type type ) {
@@ -373,29 +374,26 @@ private LangStringPreferredNameTypeIec61360 mapLangStringPreferredNameTypeIec613
373374
return createLangStringPreferredNameTypeIec61360( langString.getLanguageTag().getLanguage(), langString.getValue() );
374375
}
375376

376-
377-
private LangStringTextType createLangStringTextType(String locale, String text){
377+
private LangStringTextType createLangStringTextType( String locale, String text ) {
378378
return new DefaultLangStringTextType.Builder().language( locale ).text( text ).build();
379379
}
380380

381-
private LangStringNameType createLangStringNameType(String locale, String text){
381+
private LangStringNameType createLangStringNameType( String locale, String text ) {
382382
return new DefaultLangStringNameType.Builder().language( locale ).text( text ).build();
383383
}
384384

385-
private LangStringShortNameTypeIec61360 createLangStringShortNameTypeIec61360(String locale, String text){
385+
private LangStringShortNameTypeIec61360 createLangStringShortNameTypeIec61360( String locale, String text ) {
386386
return new DefaultLangStringShortNameTypeIec61360.Builder().language( locale ).text( text ).build();
387387
}
388388

389-
private LangStringDefinitionTypeIec61360 createLangStringDefinitionTypeIec61360(String locale, String text){
389+
private LangStringDefinitionTypeIec61360 createLangStringDefinitionTypeIec61360( String locale, String text ) {
390390
return new DefaultLangStringDefinitionTypeIec61360.Builder().language( locale ).text( text ).build();
391391
}
392392

393-
private LangStringPreferredNameTypeIec61360 createLangStringPreferredNameTypeIec61360(String locale, String text){
393+
private LangStringPreferredNameTypeIec61360 createLangStringPreferredNameTypeIec61360( String locale, String text ) {
394394
return new DefaultLangStringPreferredNameTypeIec61360.Builder().language( locale ).text( text ).build();
395395
}
396396

397-
398-
399397
private Reference buildReferenceToEnumValue( final Enumeration enumeration, final Object value ) {
400398
final Key key =
401399
new DefaultKey.Builder()
@@ -483,14 +481,14 @@ private void createConceptDescription( final Aspect aspect, final Context contex
483481

484482
private EmbeddedDataSpecification extractEmbeddedDataSpecification( final Property property ) {
485483
return new DefaultEmbeddedDataSpecification.Builder()
486-
.dataSpecification( buildReferenceForSeeElement( property.getAspectModelUrn().toString() ) )
484+
.dataSpecification( buildReferenceForSeeElement( property.getAspectModelUrn().toString() ) )
487485
.dataSpecificationContent( extractDataSpecificationContent( property ) )
488486
.build();
489487
}
490488

491489
private EmbeddedDataSpecification extractEmbeddedDataSpecification( final Aspect aspect ) {
492490
return new DefaultEmbeddedDataSpecification.Builder()
493-
.dataSpecification( buildReferenceForSeeElement( aspect.getAspectModelUrn().toString() ) )
491+
.dataSpecification( buildReferenceForSeeElement( aspect.getAspectModelUrn().toString() ) )
494492
.dataSpecificationContent( extractDataSpecificationContent( aspect ) )
495493
.build();
496494
}
@@ -502,8 +500,8 @@ private DataSpecificationIec61360 extractDataSpecificationContent( final Propert
502500
.collect( Collectors.toList() );
503501

504502
final List<LangStringPreferredNameTypeIec61360> preferredNames = property.getPreferredNames().size() > 0 ?
505-
property.getPreferredNames().stream().map( this::mapLangStringPreferredNameTypeIec61360 ).collect( Collectors.toList()) :
506-
Collections.singletonList(createLangStringPreferredNameTypeIec61360(DEFAULT_LOCALE, property.getName()));
503+
property.getPreferredNames().stream().map( this::mapLangStringPreferredNameTypeIec61360 ).collect( Collectors.toList() ) :
504+
Collections.singletonList( createLangStringPreferredNameTypeIec61360( DEFAULT_LOCALE, property.getName() ) );
507505

508506
return new DefaultDataSpecificationIec61360.Builder()
509507
.definition( definitions )
@@ -513,16 +511,15 @@ private DataSpecificationIec61360 extractDataSpecificationContent( final Propert
513511
.build();
514512
}
515513

516-
517514
private DataSpecificationIec61360 extractDataSpecificationContent( final Aspect aspect ) {
518-
List<LangStringPreferredNameTypeIec61360> preferredNames = aspect.getPreferredNames().size() > 0 ?
519-
aspect.getPreferredNames().stream().map( this::mapLangStringPreferredNameTypeIec61360 ).collect( Collectors.toList()) :
520-
Collections.singletonList(createLangStringPreferredNameTypeIec61360(DEFAULT_LOCALE, aspect.getName()));
515+
List<LangStringPreferredNameTypeIec61360> preferredNames = aspect.getPreferredNames().size() > 0 ?
516+
aspect.getPreferredNames().stream().map( this::mapLangStringPreferredNameTypeIec61360 ).collect( Collectors.toList() ) :
517+
Collections.singletonList( createLangStringPreferredNameTypeIec61360( DEFAULT_LOCALE, aspect.getName() ) );
521518

522-
return new DefaultDataSpecificationIec61360.Builder()
523-
.definition( aspect.getDescriptions().stream().map( this::mapDefinitionIec61360 ).collect( Collectors.toList()) )
524-
.preferredName( preferredNames )
525-
.build();
519+
return new DefaultDataSpecificationIec61360.Builder()
520+
.definition( aspect.getDescriptions().stream().map( this::mapDefinitionIec61360 ).collect( Collectors.toList() ) )
521+
.preferredName( preferredNames )
522+
.build();
526523

527524
}
528525

@@ -595,7 +592,8 @@ public Environment visitSet(
595592
final org.eclipse.esmf.characteristic.Set set, final Context context ) {
596593
final SubmodelElementBuilder builder =
597594
( property ) ->
598-
new DefaultSubmodelElementCollection.Builder() //TODO according to the standard document this should be SubmodelEleementStruct. However, this type is not available in AAS4J
595+
new DefaultSubmodelElementCollection.Builder() //TODO according to the standard document this should be SubmodelEleementStruct. However,
596+
// this type is not available in AAS4J
599597
.idShort( ID_PREFIX + property.getName() )
600598
.displayName( mapName( property.getPreferredNames() ) )
601599
.description( mapText( property.getDescriptions() ) )

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

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -163,7 +163,7 @@ void testGenerateAasxFromBammAspectWithQuantifiable() throws IOException, Deseri
163163

164164
final DataSpecificationContent dataSpecificationContent = getDataSpecificationIEC61360( "urn:samm:org.eclipse.esmf.test:1.0.0#testProperty", env );
165165

166-
assertEquals( "percent", ((DataSpecificationIec61360)dataSpecificationContent).getUnit(), "Unit is not percent" );
166+
assertEquals( "percent", ((DataSpecificationIec61360) dataSpecificationContent).getUnit(), "Unit is not percent" );
167167
}
168168

169169
@Test
@@ -216,14 +216,14 @@ void testGenerateAasxFromBammAspectWithEnumeration() throws IOException, Deseria
216216
final DataSpecificationIec61360 dataSpecificationContent =
217217
(DataSpecificationIec61360)
218218
env.getConceptDescriptions().stream()
219-
.filter( x -> x.getIdShort().equals( "id_TestEnumeration" ) )
220-
.findFirst()
221-
.get()
222-
.getEmbeddedDataSpecifications()
223-
.stream()
224-
.findFirst()
225-
.get()
226-
.getDataSpecificationContent();
219+
.filter( x -> x.getIdShort().equals( "id_TestEnumeration" ) )
220+
.findFirst()
221+
.get()
222+
.getEmbeddedDataSpecifications()
223+
.stream()
224+
.findFirst()
225+
.get()
226+
.getDataSpecificationContent();
227227
assertEquals( 3, dataSpecificationContent.getValueList().getValueReferencePairs().size() );
228228

229229
assertEquals( 1, env.getSubmodels().size() );
@@ -246,11 +246,11 @@ public void testGeneration( final TestAspect testAspect ) throws IOException, De
246246
byte[] xmlFile = baos.toByteArray();
247247
final Environment env = loadAASX( new ByteArrayInputStream( xmlFile ) );
248248
assertTrue( env.getSubmodels().size() >= 1, "No Submodel in AAS present." );
249-
try{
249+
try {
250250
validate( new ByteArrayInputStream( xmlFile ) );
251-
}catch(SAXException e){
252-
String model = "AAS XML file causing the Exception. \n" + new String(xmlFile, StandardCharsets.UTF_8);
253-
throw new SAXException(model, e);
251+
} catch ( SAXException e ) {
252+
String model = "AAS XML file causing the Exception. \n" + new String( xmlFile, StandardCharsets.UTF_8 );
253+
throw new SAXException( model, e );
254254
}
255255

256256
}
@@ -287,18 +287,17 @@ private ByteArrayOutputStream getByteArrayOutputStreamFromAspect( final TestAspe
287287
return generator.generateXmlOutput( aspect );
288288
}
289289

290-
private void validate(ByteArrayInputStream xmlStream) throws IOException, SAXException {
291-
SchemaFactory factory =
292-
SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI);
290+
private void validate( ByteArrayInputStream xmlStream ) throws IOException, SAXException {
291+
SchemaFactory factory =
292+
SchemaFactory.newInstance( XMLConstants.W3C_XML_SCHEMA_NS_URI );
293293

294-
Schema schema = factory.newSchema(
295-
new StreamSource(getClass().getResourceAsStream( XML_XSD_AAS_SCHEMA_LOCATION ) ) );
296-
Validator validator = schema.newValidator();
297-
validator.validate(new StreamSource( xmlStream ), null);
294+
Schema schema = factory.newSchema(
295+
new StreamSource( getClass().getResourceAsStream( XML_XSD_AAS_SCHEMA_LOCATION ) ) );
296+
Validator validator = schema.newValidator();
297+
validator.validate( new StreamSource( xmlStream ), null );
298298

299299
}
300300

301-
302301
private Aspect loadAspect( final TestAspect testAspect ) {
303302
final VersionedModel model = TestResources.getModel( testAspect, KnownVersion.getLatest() ).get();
304303
return AspectModelLoader.getSingleAspect( model ).get();

0 commit comments

Comments
 (0)