Skip to content

Commit 6735c3f

Browse files
committed
Adjust formatting
Adds comment about how the URL of a jar is handled
1 parent fa3ecba commit 6735c3f

File tree

4 files changed

+21
-30
lines changed

4 files changed

+21
-30
lines changed

core/sds-aspect-meta-model-java/src/main/java/io/openmanufacturing/sds/metamodel/impl/BaseImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public int hashCode() {
125125

126126
@Override
127127
public int compareTo( BaseImpl o ) {
128-
if(this.urn.isPresent() && o.urn.isPresent())
128+
if ( this.urn.isPresent() && o.urn.isPresent() )
129129
return this.urn.get().compareTo( o.urn.get() );
130130
return Comparator
131131
.comparing( BaseImpl::getMetaModelVersion )

core/sds-aspect-model-java-generator/src/test/java/io/openmanufacturing/sds/aspectmodel/java/StaticMetaModelJavaGeneratorTest.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,6 @@ ImmutableMap.<String, Object> builder().put( "NAMESPACE", String.class ).put( "M
235235
}
236236

237237
@ParameterizedTest
238-
// @MethodSource( value = "allVersions" )
239238
@MethodSource( value = "latestVersion" )
240239
public void testGenerateStaticMetaModelWithConstraints( final KnownVersion metaModelVersion ) throws IOException {
241240
final TestAspect aspect = TestAspect.ASPECT_WITH_CONSTRAINTS;

core/sds-aspect-model-resolver/src/main/java/io/openmanufacturing/sds/aspectmodel/resolver/ClasspathStrategy.java

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
* Copyright (c) 2021 Robert Bosch Manufacturing Solutions GmbH
33
*
44
* See the AUTHORS file(s) distributed with this work for additional
5-
* information regarding authorship.
5+
* information regarding authorship.
66
*
77
* This Source Code Form is subject to the terms of the Mozilla Public
88
* License, v. 2.0. If a copy of the MPL was not distributed with this
@@ -97,8 +97,8 @@ protected URL resourceUrl( final String directory, final String filename ) {
9797

9898
protected Stream<String> filesInDirectory( final String directory ) {
9999
try {
100-
final Optional<File> file = getDirectoryFile(directory);
101-
if(file.isPresent() && file.get().isFile()) {
100+
final Optional<File> file = getDirectoryFile( directory );
101+
if ( file.isPresent() && file.get().isFile() ) {
102102
return getFilesFromJar( directory, file.get() );
103103
} else {
104104
return getFilesFromResources( directory );
@@ -110,15 +110,16 @@ protected Stream<String> filesInDirectory( final String directory ) {
110110
}
111111

112112
private Optional<File> getDirectoryFile( String directory ) {
113+
// The incoming URL will look like this: jar:file:/pathToJar/o.jar/packageName/className
114+
// In case we run the code from a jar. Because of that we need to deconstruct the path to get the path to the jar only and remove the unwanted part of the URL.
113115
final URL url = getClass().getClassLoader().getResource( directory );
114-
if(url == null)
115-
{
116+
if ( url == null ) {
116117
return Optional.empty();
117118
}
118119
final String urlString = url.toString();
119120
final int jarIndex = urlString.indexOf( ".jar" );
120-
final String path = jarIndex > 0 ? urlString.substring( 0, jarIndex +4 ).replace( "jar:file:", "" ) : urlString;
121-
return Optional.of(new File(path));
121+
final String path = jarIndex > 0 ? urlString.substring( 0, jarIndex + 4 ).replace( "jar:file:", "" ) : urlString;
122+
return Optional.of( new File( path ) );
122123
}
123124

124125
private Stream<String> getFilesFromResources( String directory ) throws IOException {
@@ -135,13 +136,11 @@ private Stream<String> getFilesFromJar( String directory, File jarFile ) throws
135136
final JarFile jar = new JarFile( jarFile );
136137
final Enumeration<JarEntry> entries = jar.entries();
137138
final String dir = directory.endsWith( "/" ) ? directory : directory + "/";
138-
while(entries.hasMoreElements()) {
139+
while ( entries.hasMoreElements() ) {
139140
final String name = entries.nextElement().getName();
140-
if(name.startsWith( dir ))
141-
{
141+
if ( name.startsWith( dir ) ) {
142142
final String fileName = name.replace( dir, "" );
143-
if(StringUtils.isNotEmpty( fileName ))
144-
{
143+
if ( StringUtils.isNotEmpty( fileName ) ) {
145144
fileList.add( fileName );
146145
}
147146
}

core/sds-test-aspect-models/src/main/resources/valid/bamm_2_0_0/io.openmanufacturing.test/1.0.0/AspectWithExtendedEntity.ttl

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,7 @@
1616
@prefix unit: <urn:bamm:io.openmanufacturing:unit:2.0.0#> .
1717
@prefix xsd: <http://www.w3.org/2001/XMLSchema#> .
1818

19-
:AspectWithExtendedEntity
20-
a bamm:Aspect ;
19+
:AspectWithExtendedEntity a bamm:Aspect ;
2120
bamm:properties ( :testProperty ) ;
2221
bamm:operations ( ) .
2322

@@ -29,29 +28,23 @@
2928
bamm:characteristic [ a bamm-c:SortedSet ;
3029
bamm:dataType :TestEntity ] .
3130

32-
:TestEntity
33-
a bamm:Entity ;
34-
bamm:extends :ParentTestEntity ;
31+
:TestEntity a bamm:Entity ;
32+
bamm:extends :ParentTestEntity ;
3533
bamm:properties ( ) .
3634

37-
:ParentTestEntity
38-
a bamm:AbstractEntity ;
39-
bamm:extends :ParentOfParentEntity ;
35+
:ParentTestEntity a bamm:AbstractEntity ;
36+
bamm:extends :ParentOfParentEntity ;
4037
bamm:properties ( :parentString ) .
4138

42-
:ParentOfParentEntity
43-
a bamm:AbstractEntity ;
39+
:ParentOfParentEntity a bamm:AbstractEntity ;
4440
bamm:properties ( :parentOfParentString ) .
4541

46-
:StringCode
47-
a bamm-c:Code ;
42+
:StringCode a bamm-c:Code ;
4843
bamm:dataType xsd:string .
4944

50-
:parentString
51-
a bamm:Property ;
45+
:parentString a bamm:Property ;
5246
bamm:characteristic :StringCode .
5347

54-
:parentOfParentString
55-
a bamm:Property ;
48+
:parentOfParentString a bamm:Property ;
5649
bamm:characteristic :StringCode .
5750

0 commit comments

Comments
 (0)