Skip to content

Commit cdf9353

Browse files
github-actionsgithub-actions
github-actions
authored and
github-actions
committed
Formatted with Google Java Formatter
1 parent f239d89 commit cdf9353

19 files changed

+59
-64
lines changed
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package com.examplehub.basics.constant;
22

3-
public class FinalExample {
4-
}
3+
public class FinalExample {}
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
11
package com.examplehub.basics.conversion;
22

3-
public class TypeConversionExample {
4-
}
3+
public class TypeConversionExample {}

src/main/java/com/examplehub/basics/function/ModifyFunctionArgs.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.examplehub.basics.function;
22

33
public class ModifyFunctionArgs {
4-
static class MyObj{
4+
static class MyObj {
55
public int age = -1;
66
}
77

src/main/java/com/examplehub/designpatterns/singleton/SingletonExample1.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,9 @@
22

33
public class SingletonExample1 {
44
private static final SingletonExample1 INSTANCE = new SingletonExample1();
5-
private SingletonExample1(){
65

7-
}
6+
private SingletonExample1() {}
7+
88
public static SingletonExample1 getInstance() {
99
return INSTANCE;
1010
}

src/main/java/com/examplehub/designpatterns/singleton/SingletonExample2.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ public class SingletonExample2 {
99
*/
1010
INSTANCE = new SingletonExample2();
1111
}
12-
private SingletonExample2(){
13-
}
12+
13+
private SingletonExample2() {}
14+
1415
public static SingletonExample2 getInstance() {
1516
return INSTANCE;
1617
}

src/main/java/com/examplehub/designpatterns/singleton/SingletonExample4.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
public class SingletonExample4 {
44
private static SingletonExample4 INSTANCE;
55

6-
private SingletonExample4(){
7-
}
6+
private SingletonExample4() {}
87

98
public static SingletonExample4 getInstance() {
109
if (INSTANCE == null) {

src/main/java/com/examplehub/designpatterns/singleton/SingletonExample5.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,7 @@
33
public class SingletonExample5 {
44
private static SingletonExample5 INSTANCE;
55

6-
private SingletonExample5(){
7-
}
6+
private SingletonExample5() {}
87

98
public static SingletonExample5 getInstance() {
109
if (INSTANCE == null) {

src/main/java/com/examplehub/designpatterns/singleton/SingletonExample6.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@
22

33
public class SingletonExample6 {
44

5-
private SingletonExample6(){
6-
}
5+
private SingletonExample6() {}
76

87
private static final class InstanceHolder {
98
private static final SingletonExample6 INSTANCE = new SingletonExample6();

src/test/java/com/examplehub/basics/chars/StringBuilderExampleTest.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@ void testInitCapacity() {
1818
String secondStr = "987654321";
1919
String thirdStr = "abcef";
2020

21-
StringBuilder builder = new StringBuilder(firstStr.length() + secondStr.length() + thirdStr.length());
22-
assertEquals("123456789987654321abcef", builder.append(firstStr).append(secondStr).append(thirdStr).toString());
21+
StringBuilder builder =
22+
new StringBuilder(firstStr.length() + secondStr.length() + thirdStr.length());
23+
assertEquals(
24+
"123456789987654321abcef",
25+
builder.append(firstStr).append(secondStr).append(thirdStr).toString());
2326
}
2427
}

src/test/java/com/examplehub/basics/chars/StringExampleTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ void testPlusOperator() {
2929
assertEquals("3Hi4", 3 + "Hi" + 4);
3030
assertEquals("Hi10", "Hi" + 0xA);
3131
}
32+
3233
@Test
3334
void testEqual() {
3435
String s1 = "hello";
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
11
package com.examplehub.basics.constant;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.*;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class FinalExampleTest {
88
@Test
99
void test() {
1010
final double PI = 3.1415927;
1111
assertEquals(3.1415927, PI);
1212

13-
//PI = 3.14; // cannot assign a value to final variable PI
13+
// PI = 3.14; // cannot assign a value to final variable PI
1414
}
1515

1616
@Test
1717
void testWithoutInit() {
1818
final double PI;
19-
//System.out.println(PI); // variable PI might not have been initialized
19+
// System.out.println(PI); // variable PI might not have been initialized
2020
}
2121

2222
@Test
@@ -28,9 +28,9 @@ void testInitLater() {
2828

2929
@Test
3030
void testStatic() {
31-
class MyMath {
31+
class MyMath {
3232
public static final double PI = 3.1415927;
3333
}
3434
assertEquals(3.1415927, MyMath.PI);
3535
}
36-
}
36+
}
Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,23 @@
11
package com.examplehub.basics.conversion;
22

3-
import org.junit.jupiter.api.Test;
4-
import org.junit.jupiter.api.function.Executable;
5-
63
import static org.junit.jupiter.api.Assertions.*;
74

5+
import org.junit.jupiter.api.Test;
6+
87
class TypeConversionExampleTest {
98
@Test
109
void testObjectConversion() {
11-
class A {
12-
13-
}
14-
class B {
15-
16-
}
10+
class A {}
11+
class B {}
1712
// A a = new B(); // incompatible types: B cannot be converted to A
1813

19-
class Father {
20-
}
21-
class Son extends Father {
22-
}
14+
class Father {}
15+
class Son extends Father {}
2316
Father father = new Son(); // ok
24-
assertThrows(ClassCastException.class, () -> {
25-
Son son = (Son) new Father();
26-
});
17+
assertThrows(
18+
ClassCastException.class,
19+
() -> {
20+
Son son = (Son) new Father();
21+
});
2722
}
28-
}
23+
}

src/test/java/com/examplehub/basics/function/ModifyFunctionArgsTest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.examplehub.basics.function;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.*;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class ModifyFunctionArgsTest {
88
@Test
99
void test() {
@@ -19,4 +19,4 @@ void test() {
1919
assertEquals(-1, array[0]);
2020
assertEquals(1, obj.age);
2121
}
22-
}
22+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.examplehub.designpatterns.singleton;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.*;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class SingletonExample1Test {
88
@Test
99
void test() {
1010
SingletonExample1 firstInstance = SingletonExample1.getInstance();
1111
SingletonExample1 secondInstance = SingletonExample1.getInstance();
1212
assertEquals(firstInstance.hashCode(), secondInstance.hashCode());
1313
}
14-
}
14+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.examplehub.designpatterns.singleton;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.*;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class SingletonExample2Test {
88
@Test
99
void test() {
1010
SingletonExample2 firstInstance = SingletonExample2.getInstance();
1111
SingletonExample2 secondInstance = SingletonExample2.getInstance();
1212
assertEquals(firstInstance.hashCode(), secondInstance.hashCode());
1313
}
14-
}
14+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package com.examplehub.designpatterns.singleton;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.*;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class SingletonExample3Test {
88
@Test
99
void test() {
1010
SingletonExample3 firstInstance = SingletonExample3.INSTANCE;
1111
SingletonExample3 secondInstance = SingletonExample3.INSTANCE;
1212
assertEquals(firstInstance.hashCode(), secondInstance.hashCode());
1313
}
14-
}
14+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.examplehub.designpatterns.singleton;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.*;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class SingletonExample4Test {
88
@Test
99
void test() {
@@ -14,6 +14,6 @@ void test() {
1414

1515
@Test
1616
void testMultiThreads() {
17-
//TODO
17+
// TODO
1818
}
19-
}
19+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.examplehub.designpatterns.singleton;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.*;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class SingletonExample5Test {
88
@Test
99
void test() {
@@ -14,6 +14,6 @@ void test() {
1414

1515
@Test
1616
void testMultiThreads() {
17-
//TODO
17+
// TODO
1818
}
19-
}
19+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
package com.examplehub.designpatterns.singleton;
22

3-
import org.junit.jupiter.api.Test;
4-
53
import static org.junit.jupiter.api.Assertions.*;
64

5+
import org.junit.jupiter.api.Test;
6+
77
class SingletonExample6Test {
88
@Test
99
void test() {
@@ -14,6 +14,6 @@ void test() {
1414

1515
@Test
1616
void testMultiThreads() {
17-
//TODO
17+
// TODO
1818
}
19-
}
19+
}

0 commit comments

Comments
 (0)