Skip to content

Commit eadec22

Browse files
committed
format code with google plugin
1 parent 15bc850 commit eadec22

File tree

448 files changed

+13334
-14353
lines changed

Some content is hidden

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

448 files changed

+13334
-14353
lines changed

src/main/java/Advances/Annotation/MyAnnotation.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44

55
public @interface MyAnnotation {
66

7-
String value() default "hello";
7+
String value() default "hello";
88
}

src/main/java/Advances/Annotation/MyAnnotation2.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@
77

88
@Retention(RetentionPolicy.RUNTIME)
99
public @interface MyAnnotation2 {
10-
String value() default "123";
10+
String value() default "123";
1111
}

src/main/java/Advances/Annotation/MyAnnotation3.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
@Target({ElementType.TYPE, ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
1111
public @interface MyAnnotation3 {
1212

13-
String value() default "hello";
13+
String value() default "hello";
1414
}

src/main/java/Advances/Annotation/MyAnnotations.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,9 @@
55
import java.lang.annotation.ElementType;
66
import java.lang.annotation.Target;
77

8-
/**
9-
* an array of Annotation for using multiple Annotations at once
10-
*
11-
*/
12-
8+
/** an array of Annotation for using multiple Annotations at once */
139
@Target({ElementType.TYPE})
1410
public @interface MyAnnotations {
1511

16-
MyAnnotation3[] value();
12+
MyAnnotation3[] value();
1713
}

src/main/java/Advances/Annotation/demo1.java

Lines changed: 49 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -6,93 +6,78 @@
66
// https://www.youtube.com/watch?v=hKzyUbQaorM&list=PLmOn9nNkQxJH0qBIrtV6otI0Ep4o2q67A&index=509
77

88
/**
9-
* Annotation demo 1
9+
* Annotation demo 1
1010
*
11-
* 1) Annotation is a feature in JDK >= 5.0
11+
* <p>1) Annotation is a feature in JDK >= 5.0
1212
*
13-
* 2) Annotation is a special `sign` of the code, these sign
14-
* can be compiled, overloaded, and read during runtime.
15-
* Developers can "insert" extra information to the code
16-
* without any code change via Annotation
13+
* <p>2) Annotation is a special `sign` of the code, these sign can be compiled, overloaded, and
14+
* read during runtime. Developers can "insert" extra information to the code without any code
15+
* change via Annotation
1716
*
18-
* 3) Annotation can be used as `modifier` (e.g. public, private, static...);
19-
* can be used in package, class, constructor, method, variables, parameters...
20-
* (these information are stored in name=value)
17+
* <p>3) Annotation can be used as `modifier` (e.g. public, private, static...); can be used in
18+
* package, class, constructor, method, variables, parameters... (these information are stored in
19+
* name=value)
2120
*
22-
* 4) use cases
23-
* - auto documentation
24-
* - check during compile ( @Override, @Deprecated, @SuppressWarnings)
25-
* - track code dependency, replace some config functionalities
21+
* <p>4) use cases - auto documentation - check during compile
22+
* ( @Override, @Deprecated, @SuppressWarnings) - track code dependency, replace some config
23+
* functionalities
2624
*
27-
* 5) how to make user-defined-Annotation
28-
* - refer @SuppressWarnings
29-
* - step 1) init with `public @interface`
30-
* - step 2) define internal component, usually use `value` (e.g. String value();)
31-
* - we can aldo give default value to it (e.g. String value() default "hello";)
32-
* - step 3) if there is no arg in user-defined-Annotation, then it's just a "mark" purpose Annotation
25+
* <p>5) how to make user-defined-Annotation - refer @SuppressWarnings - step 1) init with
26+
* `public @interface` - step 2) define internal component, usually use `value` (e.g. String
27+
* value();) - we can aldo give default value to it (e.g. String value() default "hello";) - step 3)
28+
* if there is no arg in user-defined-Annotation, then it's just a "mark" purpose Annotation
3329
*
34-
* 6) JDK meta-Annotation : Annotation's Annotation
35-
* - Retention : define life cycle of the Annotation
36-
* - Target
37-
* - Documented
38-
* - Inherited
30+
* <p>6) JDK meta-Annotation : Annotation's Annotation - Retention : define life cycle of the
31+
* Annotation - Target - Documented - Inherited
3932
*
40-
* 7) Annotation new features since JDK 8
33+
* <p>7) Annotation new features since JDK 8
4134
*
42-
* - repeatable annotation
43-
* - step 1) add @Repeatable on MyAnnotation3
44-
* - step 2) use MyAnnotation3 in MyAnnotations
35+
* <p>- repeatable annotation - step 1) add @Repeatable on MyAnnotation3 - step 2) use MyAnnotation3
36+
* in MyAnnotations
4537
*
46-
* - Element type annotation
47-
* - ElementType.TYPE_PARAMETER
48-
* - ElementType.TYPE_USE
49-
* - example : https://github.com/yennanliu/JavaHelloWorld/blob/main/src/main/java/Advances/Annotation/demo2.java
38+
* <p>- Element type annotation - ElementType.TYPE_PARAMETER - ElementType.TYPE_USE - example :
39+
* https://github.com/yennanliu/JavaHelloWorld/blob/main/src/main/java/Advances/Annotation/demo2.java
5040
*
51-
* 8) Annotation used A LOT in framework.
52-
* e.g. spring MVC, android dev ...
41+
* <p>8) Annotation used A LOT in framework. e.g. spring MVC, android dev ...
5342
*/
54-
5543
public class demo1 {
56-
public static void main(String[] args) {
57-
58-
}
44+
public static void main(String[] args) {}
5945
}
6046

6147
/** demo 1 : basic annotation usage */
62-
//@MyAnnotation(value="hello") // if not default value in MyAnnotation, then we need give in a value
48+
// @MyAnnotation(value="hello") // if not default value in MyAnnotation, then we need give in a
49+
// value
6350
@MyAnnotation // if there's default value in MyAnnotation
64-
class Person{
65-
// attr
66-
private String name;
67-
private int age;
51+
class Person {
52+
// attr
53+
private String name;
54+
private int age;
6855

69-
// constructor
70-
@MyAnnotation
71-
public Person(){
56+
// constructor
57+
@MyAnnotation
58+
public Person() {}
7259

73-
}
74-
75-
// method
76-
@MyAnnotation
77-
public void myPrint(String x){
78-
System.out.println(x);
79-
}
60+
// method
61+
@MyAnnotation
62+
public void myPrint(String x) {
63+
System.out.println(x);
64+
}
8065
}
8166

8267
/** demo 2 : use multiple annotations via array */
83-
@MyAnnotations({@MyAnnotation3, @MyAnnotation3(value="456")}) // before JDK 8
84-
class Person2{
85-
// attr
86-
private String name;
87-
private int age;
68+
@MyAnnotations({@MyAnnotation3, @MyAnnotation3(value = "456")}) // before JDK 8
69+
class Person2 {
70+
// attr
71+
private String name;
72+
private int age;
8873
}
8974

9075
/** demo 3 : use multiple annotations via repeatable annotations */
9176
// after JDK 8
9277
@MyAnnotation3()
93-
@MyAnnotation3(value="lol")
94-
class Person3{
95-
// attr
96-
private String name;
97-
private int age;
98-
}
78+
@MyAnnotation3(value = "lol")
79+
class Person3 {
80+
// attr
81+
private String name;
82+
private int age;
83+
}

src/main/java/Advances/Annotation/demo2.java

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,21 +4,20 @@
44

55
import java.util.ArrayList;
66

7-
public class demo2 {
8-
}
9-
7+
public class demo2 {}
108

119
// T is generic type
12-
// we can decorate the generic type with user-defined-annotation (@MyAnnotation3) via `ElementType.TYPE_USE` in @Target({ElementType.TYPE, ElementType.TYPE_PARAMETER, ElementType.TYPE_USE})
13-
class Generic<@MyAnnotation3 T>{
14-
// attr
10+
// we can decorate the generic type with user-defined-annotation (@MyAnnotation3) via
11+
// `ElementType.TYPE_USE` in @Target({ElementType.TYPE, ElementType.TYPE_PARAMETER,
12+
// ElementType.TYPE_USE})
13+
class Generic<@MyAnnotation3 T> {
14+
// attr
1515

16-
// method
17-
public void show() throws @MyAnnotation3 RuntimeException{
16+
// method
17+
public void show() throws @MyAnnotation3 RuntimeException {
1818

19-
ArrayList<@MyAnnotation3 String> list = new ArrayList<> ();
19+
ArrayList<@MyAnnotation3 String> list = new ArrayList<>();
2020

21-
int num = (@MyAnnotation3 int) 10L;
22-
}
23-
24-
}
21+
int num = (@MyAnnotation3 int) 10L;
22+
}
23+
}

src/main/java/Advances/Annotation/test1.java

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@
77
import org.junit.jupiter.api.Test;
88

99
public class test1 {
10-
private static Object[] array;
11-
private static int total;
10+
private static Object[] array;
11+
private static int total;
1212

13-
@BeforeAll
14-
public static void beforeAll(){
15-
System.out.println("BeforeAll ...");
16-
}
13+
@BeforeAll
14+
public static void beforeAll() {
15+
System.out.println("BeforeAll ...");
16+
}
1717

18-
@Test
19-
public void myTest1(){
20-
System.out.println("myTest1 ...");
21-
int int1 = 10;
22-
assert (int1==10);
23-
}
18+
@AfterAll
19+
public static void afterAll() {
20+
System.out.println("AfterAll ...");
21+
}
2422

25-
@AfterAll
26-
public static void afterAll(){
27-
System.out.println("AfterAll ...");
28-
}
23+
@Test
24+
public void myTest1() {
25+
System.out.println("myTest1 ...");
26+
int int1 = 10;
27+
assert (int1 == 10);
28+
}
2929
}

src/main/java/Advances/BigIntegerBigDecimalDemo1.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
import java.math.BigInteger;
77

88
public class BigIntegerBigDecimalDemo1 {
9-
public static void main(String[] args) {
10-
BigInteger b1 = new BigInteger("342334234543543534534");
11-
BigDecimal bd1 = new BigDecimal("1223423.34534");
12-
BigDecimal bd2 = new BigDecimal("77");
9+
public static void main(String[] args) {
10+
BigInteger b1 = new BigInteger("342334234543543534534");
11+
BigDecimal bd1 = new BigDecimal("1223423.34534");
12+
BigDecimal bd2 = new BigDecimal("77");
1313

14-
System.out.println(b1);
15-
System.out.println(bd1.divide(bd2, BigDecimal.ROUND_HALF_UP));
16-
System.out.println(bd1.divide(bd2, 15, BigDecimal.ROUND_HALF_UP));
17-
}
14+
System.out.println(b1);
15+
System.out.println(bd1.divide(bd2, BigDecimal.ROUND_HALF_UP));
16+
System.out.println(bd1.divide(bd2, 15, BigDecimal.ROUND_HALF_UP));
17+
}
1818
}

src/main/java/Advances/CalendarApi/demo1.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88
* Calendar class use class intro
99
*/
1010

11-
import org.junit.jupiter.api.Test;
1211
import java.util.Calendar;
1312
import java.util.Date;
13+
import org.junit.jupiter.api.Test;
1414

1515
/**
1616
* 1) Calendar is an abstract class

0 commit comments

Comments
 (0)