Skip to content

Commit f25136e

Browse files
authored
Apply google-java-format to all .java source files (#132)
Apply `google-java-format` to all `.java` source-files
1 parent 2570f31 commit f25136e

File tree

10 files changed

+186
-355
lines changed

10 files changed

+186
-355
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,4 @@ target/surefire-reports
3636
/target/generated-sources/openapi/.openapi-generator/api.yaml-default.sha256
3737
/target/site/jacoco/
3838
/target/jacoco.exec
39+
/target/spotless-index

pom.xml

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262
<!-- /Jacoco -->
6363

6464
<!-- Spotless -->
65-
<spotless.check.skip>true</spotless.check.skip> <!-- Unused imports causes build to fail -->
65+
<spotless.check.skip>false</spotless.check.skip> <!-- Unused imports causes build to fail -->
6666
<spotless-maven-plugin.version>2.43.0</spotless-maven-plugin.version>
6767
<googleJavaFormat.version>1.23.0</googleJavaFormat.version>
6868
<!-- /Spotless -->
@@ -410,9 +410,6 @@
410410
<version>${spotless-maven-plugin.version}</version>
411411
<configuration>
412412
<java>
413-
<includes>
414-
<include>target/generated-sources/**/*.java</include>
415-
</includes>
416413
<lineEndings>UNIX</lineEndings>
417414
<googleJavaFormat>
418415
<version>${googleJavaFormat.version}</version>
@@ -423,8 +420,17 @@
423420
<executions>
424421
<execution>
425422
<goals>
426-
<goal>check</goal>
423+
<goal>apply</goal>
427424
</goals>
425+
<phase>validate</phase>
426+
<configuration>
427+
<java>
428+
<includes>
429+
<include>src/main/**/*.java</include>
430+
<include>src/test/**/*.java</include>
431+
</includes>
432+
</java>
433+
</configuration>
428434
</execution>
429435
</executions>
430436
</plugin>

src/main/java/com/chrimle/example/annotations/TestAnnotationOne.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77

88
@Retention(RetentionPolicy.RUNTIME)
99
@Target(ElementType.TYPE)
10-
public @interface TestAnnotationOne {
11-
12-
}
10+
public @interface TestAnnotationOne {}

src/main/java/com/chrimle/example/annotations/TestAnnotationThree.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77

88
@Retention(RetentionPolicy.RUNTIME)
99
@Target(ElementType.TYPE)
10-
public @interface TestAnnotationThree {
11-
12-
}
10+
public @interface TestAnnotationThree {}

src/main/java/com/chrimle/example/annotations/TestAnnotationTwo.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,4 @@
77

88
@Retention(RetentionPolicy.RUNTIME)
99
@Target(ElementType.TYPE)
10-
public @interface TestAnnotationTwo {
11-
12-
}
10+
public @interface TestAnnotationTwo {}

src/test/java/com/chrimle/example/PluginExecution.java

Lines changed: 9 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,15 @@
11
package com.chrimle.example;
22

33
public enum PluginExecution {
4-
GENERATE_BUILDERS(
5-
"generateBuilders",
6-
true,
7-
false,
8-
false,
9-
false,
10-
false,
11-
false),
4+
GENERATE_BUILDERS("generateBuilders", true, false, false, false, false, false),
125
ADDITIONAL_ENUM_TYPE_ANNOTATIONS(
13-
"additionalEnumTypeAnnotations",
14-
false,
15-
true,
16-
false,
17-
false,
18-
false,
19-
false),
6+
"additionalEnumTypeAnnotations", false, true, false, false, false, false),
207
ADDITIONAL_MODEL_TYPE_ANNOTATIONS(
21-
"additionalModelTypeAnnotations",
22-
false,
23-
false,
24-
true,
25-
false,
26-
false,
27-
false),
28-
SERIALIZABLE_MODEL(
29-
"serializableModel",
30-
false,
31-
false,
32-
false,
33-
true,
34-
false,
35-
false),
36-
STANDARD(
37-
"standard",
38-
false,
39-
false,
40-
false,
41-
false,
42-
false,
43-
false),
44-
USE_ENUM_CASE_INSENSITIVE(
45-
"useEnumCaseInsensitive",
46-
false,
47-
false,
48-
false,
49-
false,
50-
true,
51-
false),
52-
USE_JAKARTA_EE(
53-
"useJakartaEe",
54-
false,
55-
false,
56-
false,
57-
false,
58-
false,
59-
true
60-
);
8+
"additionalModelTypeAnnotations", false, false, true, false, false, false),
9+
SERIALIZABLE_MODEL("serializableModel", false, false, false, true, false, false),
10+
STANDARD("standard", false, false, false, false, false, false),
11+
USE_ENUM_CASE_INSENSITIVE("useEnumCaseInsensitive", false, false, false, false, true, false),
12+
USE_JAKARTA_EE("useJakartaEe", false, false, false, false, false, true);
6113

6214
private final String packageName;
6315
private final boolean generateBuilders;
@@ -73,7 +25,8 @@ public enum PluginExecution {
7325
final boolean hasAdditionalEnumTypeAnnotations,
7426
final boolean hasAdditionalModelTypeAnnotations,
7527
final boolean serializableModel,
76-
final boolean useEnumCaseInsensitive, boolean useJakartaEe) {
28+
final boolean useEnumCaseInsensitive,
29+
boolean useJakartaEe) {
7730
this.packageName = packageName;
7831
this.hasAdditionalEnumTypeAnnotations = hasAdditionalEnumTypeAnnotations;
7932
this.hasAdditionalModelTypeAnnotations = hasAdditionalModelTypeAnnotations;

src/test/java/com/chrimle/example/TestSuite.java

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -14,60 +14,44 @@ public class TestSuite {
1414
@DisplayName("Testing Plugin Executions...")
1515
public void testAll(final PluginExecution pluginExecution) {
1616
for (final GeneratedClass generatedClass : GeneratedClass.values()) {
17-
assertModel(
18-
generatedClass,
19-
pluginExecution
20-
);
17+
assertModel(generatedClass, pluginExecution);
2118
}
2219
}
2320

24-
private void assertModel(final GeneratedClass generatedClass,
25-
final PluginExecution pluginExecution) {
21+
private void assertModel(
22+
final GeneratedClass generatedClass, final PluginExecution pluginExecution) {
2623

27-
final Class<?> classUnderTest = AssertionUtils.assertClassExists(
28-
getCanonicalClassName(pluginExecution, generatedClass)
29-
);
24+
final Class<?> classUnderTest =
25+
AssertionUtils.assertClassExists(getCanonicalClassName(pluginExecution, generatedClass));
3026

3127
switch (generatedClass) {
32-
case EXAMPLE_ENUM -> GeneratedEnumTestUtils.assertExampleEnum(
33-
pluginExecution, classUnderTest
34-
);
35-
case EXAMPLE_RECORD -> GeneratedRecordTestUtils.assertExampleRecord(
36-
pluginExecution, classUnderTest
37-
);
38-
case DEPRECATED_EXAMPLE_ENUM -> GeneratedEnumTestUtils.assertDeprecatedExampleEnum(
39-
pluginExecution, classUnderTest
40-
);
41-
case DEPRECATED_EXAMPLE_RECORD -> GeneratedRecordTestUtils.assertDeprecatedExampleRecord(
42-
pluginExecution, classUnderTest
43-
);
28+
case EXAMPLE_ENUM ->
29+
GeneratedEnumTestUtils.assertExampleEnum(pluginExecution, classUnderTest);
30+
case EXAMPLE_RECORD ->
31+
GeneratedRecordTestUtils.assertExampleRecord(pluginExecution, classUnderTest);
32+
case DEPRECATED_EXAMPLE_ENUM ->
33+
GeneratedEnumTestUtils.assertDeprecatedExampleEnum(pluginExecution, classUnderTest);
34+
case DEPRECATED_EXAMPLE_RECORD ->
35+
GeneratedRecordTestUtils.assertDeprecatedExampleRecord(pluginExecution, classUnderTest);
4436
case EXAMPLE_RECORD_WITH_DEFAULT_FIELDS ->
4537
GeneratedRecordTestUtils.assertExampleRecordWithDefaultFields(
46-
pluginExecution, classUnderTest
47-
);
38+
pluginExecution, classUnderTest);
4839
case EXAMPLE_RECORD_WITH_REQUIRED_FIELDS_OF_EACH_TYPE ->
4940
GeneratedRecordTestUtils.assertExampleRecordWithRequiredFieldsOfEachType(
50-
pluginExecution, classUnderTest,
41+
pluginExecution,
42+
classUnderTest,
5143
AssertionUtils.assertClassExists(
52-
getCanonicalClassName(pluginExecution,
53-
GeneratedClass.EXAMPLE_RECORD)
54-
),
44+
getCanonicalClassName(pluginExecution, GeneratedClass.EXAMPLE_RECORD)),
5545
AssertionUtils.assertClassExists(
56-
getCanonicalClassName(pluginExecution,
57-
GeneratedClass.EXAMPLE_ENUM)
58-
)
59-
);
46+
getCanonicalClassName(pluginExecution, GeneratedClass.EXAMPLE_ENUM)));
6047
case EXAMPLE_RECORD_WITH_NULLABLE_FIELDS_OF_EACH_TYPE ->
6148
GeneratedRecordTestUtils.assertExampleRecordWithNullableFieldsOfEachType(
62-
pluginExecution, classUnderTest
63-
);
49+
pluginExecution, classUnderTest);
6450
}
6551
}
6652

67-
private String getCanonicalClassName(final PluginExecution pluginExecution,
68-
final GeneratedClass generatedClass) {
69-
return generatedClass.getCanonicalClassName(
70-
pluginExecution.getPackageName());
53+
private String getCanonicalClassName(
54+
final PluginExecution pluginExecution, final GeneratedClass generatedClass) {
55+
return generatedClass.getCanonicalClassName(pluginExecution.getPackageName());
7156
}
72-
7357
}

0 commit comments

Comments
 (0)