Skip to content

Commit b36a102

Browse files
committed
add spotless formatter
1 parent 7e53f04 commit b36a102

File tree

126 files changed

+4229
-4152
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

126 files changed

+4229
-4152
lines changed

pom.xml

Lines changed: 98 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,78 @@
1010

1111
<name>alvarium-sdk</name>
1212
<url>https://alvarium.org/</url>
13-
13+
14+
<build>
15+
<plugins>
16+
<plugin>
17+
<groupId>com.diffplug.spotless</groupId>
18+
<artifactId>spotless-maven-plugin</artifactId>
19+
<version>2.43.0</version>
20+
<configuration>
21+
<formats>
22+
<format>
23+
<includes>
24+
<include>.gitattributes</include>
25+
<include>.gitignore</include>
26+
</includes>
27+
<trimTrailingWhitespace/>
28+
<endWithNewline/>
29+
30+
</format>
31+
</formats>
32+
<java>
33+
<googleJavaFormat>
34+
<version>1.17.0</version>
35+
<style>AOSP</style>
36+
<reflowLongStrings>true</reflowLongStrings>
37+
<formatJavadoc>false</formatJavadoc>
38+
</googleJavaFormat>
39+
<removeUnusedImports/>
40+
41+
<indent>
42+
<tabs>true</tabs>
43+
<spacesPerTab>2</spacesPerTab>
44+
</indent>
45+
<indent>
46+
<spaces>true</spaces>
47+
<spacesPerTab>1</spacesPerTab>
48+
</indent>
49+
50+
<licenseHeader>
51+
<content>/*******************************************************************************
52+
* Copyright 2022 Dell Inc.
53+
*
54+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
55+
* in compliance with the License. You may obtain a copy of the License at
56+
*
57+
* http://www.apache.org/licenses/LICENSE-2.0
58+
*
59+
* Unless required by applicable law or agreed to in writing, software distributed under the License
60+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
61+
* or implied. See the License for the specific language governing permissions and limitations under
62+
* the License.
63+
*******************************************************************************/
64+
</content>
65+
</licenseHeader>
66+
67+
<importOrder>
68+
<order>java,javafx,scala,com,net,org,com.twitter,static</order>
69+
</importOrder>
70+
</java>
71+
</configuration>
72+
</plugin>
73+
</plugins>
74+
</build>
75+
76+
1477
<properties>
1578
<maven.compiler.source>11</maven.compiler.source>
1679
<maven.compiler.target>11</maven.compiler.target>
80+
1781
</properties>
1882

1983
<dependencies>
20-
84+
2185
<dependency>
2286
<groupId>org.apache.httpcomponents</groupId>
2387
<artifactId>httpclient</artifactId>
@@ -30,55 +94,55 @@
3094
<version>4.11</version>
3195
<scope>test</scope>
3296
</dependency>
33-
97+
3498
<dependency>
3599
<groupId>com.google.crypto.tink</groupId>
36100
<artifactId>tink</artifactId>
37101
<version>1.6.1</version>
38102
</dependency>
39103

40104
<dependency>
41-
<groupId>com.google.code.gson</groupId>
42-
<artifactId>gson</artifactId>
43-
<version>2.8.8</version>
105+
<groupId>com.google.code.gson</groupId>
106+
<artifactId>gson</artifactId>
107+
<version>2.8.8</version>
44108
</dependency>
45109

46110
<dependency>
47-
<groupId>de.huxhorn.sulky</groupId>
48-
<artifactId>de.huxhorn.sulky.ulid</artifactId>
49-
<version>8.2.0</version>
111+
<groupId>de.huxhorn.sulky</groupId>
112+
<artifactId>de.huxhorn.sulky.ulid</artifactId>
113+
<version>8.2.0</version>
50114
</dependency>
51115

52116
<dependency>
53-
<groupId>org.eclipse.paho</groupId>
54-
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
55-
<version>1.2.5</version>
117+
<groupId>org.eclipse.paho</groupId>
118+
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
119+
<version>1.2.5</version>
120+
</dependency>
121+
122+
<dependency>
123+
<groupId>io.pravega</groupId>
124+
<artifactId>pravega-client</artifactId>
125+
<version>0.10.0</version>
126+
</dependency>
127+
128+
<dependency>
129+
<groupId>org.apache.logging.log4j</groupId>
130+
<artifactId>log4j-api</artifactId>
131+
<version>2.21.0</version>
132+
</dependency>
133+
134+
<dependency>
135+
<groupId>org.apache.logging.log4j</groupId>
136+
<artifactId>log4j-core</artifactId>
137+
<version>2.21.0</version>
138+
<scope>test</scope>
56139
</dependency>
57140

58141
<dependency>
59-
<groupId>io.pravega</groupId>
60-
<artifactId>pravega-client</artifactId>
61-
<version>0.10.0</version>
142+
<groupId>org.spdx</groupId>
143+
<artifactId>spdx-jackson-store</artifactId>
144+
<version>1.1.9.1</version>
62145
</dependency>
63146

64-
<dependency>
65-
<groupId>org.apache.logging.log4j</groupId>
66-
<artifactId>log4j-api</artifactId>
67-
<version>2.21.0</version>
68-
</dependency>
69-
70-
<dependency>
71-
<groupId>org.apache.logging.log4j</groupId>
72-
<artifactId>log4j-core</artifactId>
73-
<version>2.21.0</version>
74-
<scope>test</scope>
75-
</dependency>
76-
77-
<dependency>
78-
<groupId>org.spdx</groupId>
79-
<artifactId>spdx-jackson-store</artifactId>
80-
<version>1.1.9.1</version>
81-
</dependency>
82-
83147
</dependencies>
84148
</project>

src/main/java/com/alvarium/DefaultSdk.java

Lines changed: 36 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,16 @@
1-
21
/*******************************************************************************
3-
* Copyright 2023 Dell Inc.
4-
*
5-
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
6-
* in compliance with the License. You may obtain a copy of the License at
7-
*
8-
* http://www.apache.org/licenses/LICENSE-2.0
9-
*
10-
* Unless required by applicable law or agreed to in writing, software distributed under the License
11-
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
12-
* or implied. See the License for the specific language governing permissions and limitations under
13-
* the License.
14-
*******************************************************************************/
2+
* Copyright 2022 Dell Inc.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5+
* in compliance with the License. You may obtain a copy of the License at
6+
*
7+
* http://www.apache.org/licenses/LICENSE-2.0
8+
*
9+
* Unless required by applicable law or agreed to in writing, software distributed under the License
10+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11+
* or implied. See the License for the specific language governing permissions and limitations under
12+
* the License.
13+
*******************************************************************************/
1514
package com.alvarium;
1615

1716
import java.util.ArrayList;
@@ -39,7 +38,8 @@ public class DefaultSdk implements Sdk {
3938
private final StreamProvider stream;
4039
private final Logger logger;
4140

42-
public DefaultSdk(Annotator[] annotators, SdkInfo config, Logger logger) throws StreamException {
41+
public DefaultSdk(Annotator[] annotators, SdkInfo config, Logger logger)
42+
throws StreamException {
4343
this.annotators = annotators;
4444
this.config = config;
4545
this.logger = logger;
@@ -51,37 +51,35 @@ public DefaultSdk(Annotator[] annotators, SdkInfo config, Logger logger) throws
5151
this.logger.debug("stream provider connected successfully.");
5252
}
5353

54-
public void create(PropertyBag properties, byte[] data) throws AnnotatorException,
55-
StreamException {
54+
public void create(PropertyBag properties, byte[] data)
55+
throws AnnotatorException, StreamException {
5656
final List<Annotation> annotations = this.createAnnotations(properties, data);
5757
this.publishAnnotations(SdkAction.CREATE, annotations);
5858
this.logger.debug("data annotated and published successfully.");
5959
}
60-
60+
6161
public void create(byte[] data) throws AnnotatorException, StreamException {
6262
final PropertyBag properties = new ImmutablePropertyBag(new HashMap<String, Object>());
6363
this.create(properties, data);
6464
}
6565

66-
public void mutate(PropertyBag properties, byte[] oldData, byte[] newData) throws
67-
AnnotatorException, StreamException {
66+
public void mutate(PropertyBag properties, byte[] oldData, byte[] newData)
67+
throws AnnotatorException, StreamException {
6868
final List<Annotation> annotations = new ArrayList<Annotation>();
6969

7070
// source annotate the old data
7171
final AnnotatorFactory annotatorFactory = new AnnotatorFactory();
72-
final Annotator sourceAnnotator = annotatorFactory.getAnnotator(
73-
new AnnotatorConfig(AnnotationType.SOURCE),
74-
this.config,
75-
this.logger
76-
);
72+
final Annotator sourceAnnotator =
73+
annotatorFactory.getAnnotator(
74+
new AnnotatorConfig(AnnotationType.SOURCE), this.config, this.logger);
7775
final Annotation sourceAnnotation = sourceAnnotator.execute(properties, oldData);
7876
annotations.add(sourceAnnotation);
7977

8078
// Add annotations for new data
81-
for (Annotation annotation: this.createAnnotations(properties, newData)) {
79+
for (Annotation annotation : this.createAnnotations(properties, newData)) {
8280
// TLS is ignored in mutate to prevent needless penalization
8381
// See https://github.com/project-alvarium/alvarium-sdk-go/issues/19
84-
if(annotation.getKind() != AnnotationType.TLS) {
82+
if (annotation.getKind() != AnnotationType.TLS) {
8583
annotations.add(annotation);
8684
}
8785
}
@@ -96,8 +94,8 @@ public void mutate(byte[] oldData, byte[] newData) throws AnnotatorException, St
9694
this.mutate(properties, oldData, newData);
9795
}
9896

99-
public void transit(PropertyBag properties, byte[] data) throws AnnotatorException,
100-
StreamException {
97+
public void transit(PropertyBag properties, byte[] data)
98+
throws AnnotatorException, StreamException {
10199
final List<Annotation> annotations = this.createAnnotations(properties, data);
102100
this.publishAnnotations(SdkAction.TRANSIT, annotations);
103101
this.logger.debug("data annotated and published successfully.");
@@ -108,13 +106,13 @@ public void transit(byte[] data) throws AnnotatorException, StreamException {
108106
this.transit(properties, data);
109107
}
110108

111-
public void publish(PropertyBag properties, byte[] data) throws AnnotatorException,
112-
StreamException {
109+
public void publish(PropertyBag properties, byte[] data)
110+
throws AnnotatorException, StreamException {
113111
final List<Annotation> annotations = this.createAnnotations(properties, data);
114112
this.publishAnnotations(SdkAction.PUBLISH, annotations);
115113
this.logger.debug("data annotated and published successfully.");
116114
}
117-
115+
118116
public void publish(byte[] data) throws AnnotatorException, StreamException {
119117
final PropertyBag properties = new ImmutablePropertyBag(new HashMap<String, Object>());
120118
this.publish(properties, data);
@@ -132,12 +130,12 @@ public void close() throws StreamException {
132130
* @return
133131
* @throws AnnotatorException
134132
*/
135-
private List<Annotation> createAnnotations(PropertyBag properties, byte[] data)
133+
private List<Annotation> createAnnotations(PropertyBag properties, byte[] data)
136134
throws AnnotatorException {
137135
final List<Annotation> annotations = new ArrayList<Annotation>();
138136

139137
// Annotate incoming data
140-
for (Annotator annotator: this.annotators) {
138+
for (Annotator annotator : this.annotators) {
141139
final Annotation annotation = annotator.execute(properties, data);
142140
annotations.add(annotation);
143141
}
@@ -146,22 +144,19 @@ private List<Annotation> createAnnotations(PropertyBag properties, byte[] data)
146144
}
147145

148146
/**
149-
* Wraps the annotation list with a publish wrapper that specifies the SDK action and the
147+
* Wraps the annotation list with a publish wrapper that specifies the SDK action and the
150148
* content type
151149
* @param action
152150
* @param annotations
153151
* @throws StreamException
154152
*/
155-
private void publishAnnotations(SdkAction action, List<Annotation> annotations)
153+
private void publishAnnotations(SdkAction action, List<Annotation> annotations)
156154
throws StreamException {
157155
final AnnotationList annotationList = new AnnotationList(annotations);
158-
156+
159157
// publish list of annotations to the StreamProvider
160-
final PublishWrapper wrapper = new PublishWrapper(
161-
action,
162-
annotationList.getClass().getName(),
163-
annotationList
164-
);
158+
final PublishWrapper wrapper =
159+
new PublishWrapper(action, annotationList.getClass().getName(), annotationList);
165160
this.stream.publish(wrapper);
166161
}
167162
}

0 commit comments

Comments
 (0)