Skip to content

Commit 4fc2f5b

Browse files
committed
code opt
1 parent 34398bd commit 4fc2f5b

10 files changed

Lines changed: 220 additions & 60 deletions

File tree

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0"
3+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
5+
<modelVersion>4.0.0</modelVersion>
6+
<groupId>com.wdbyte.core-java-modules</groupId>
7+
<artifactId>core-java-22</artifactId>
8+
<version>1.0.0-SNAPSHOT</version>
9+
<properties>
10+
<maven.compiler.source>22</maven.compiler.source>
11+
<maven.compiler.target>22</maven.compiler.target>
12+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
13+
</properties>
14+
</project>
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.wdbyte;
2+
3+
/**
4+
* @author niulang
5+
* @date 2025/04/28
6+
*/
7+
//TIP To <b>Run</b> code, press <shortcut actionId="Run"/> or
8+
// click the <icon src="AllIcons.Actions.Execute"/> icon in the gutter.
9+
public class Main {
10+
public static void main(String[] args) {
11+
//TIP Press <shortcut actionId="ShowIntentionActions"/> with your caret at the highlighted text
12+
// to see how IntelliJ IDEA suggests fixing it.
13+
System.out.printf("Hello and welcome!");
14+
15+
for (int i = 1; i <= 5; i++) {
16+
//TIP Press <shortcut actionId="Debug"/> to start debugging your code. We have set one <icon src="AllIcons.Debugger.Db_set_breakpoint"/> breakpoint
17+
// for you, but you can always add more by pressing <shortcut actionId="ToggleLineBreakpoint"/>.
18+
System.out.println("i = " + i);
19+
}
20+
}
21+
}

core-java-modules/core-java-8/pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,6 @@
3535
<groupId>org.junit.jupiter</groupId>
3636
<artifactId>junit-jupiter</artifactId>
3737
</dependency>
38-
<dependency>
39-
<groupId>org.projectlombok</groupId>
40-
<artifactId>lombok</artifactId>
41-
<version>1.18.22</version>
42-
</dependency>
4338
</dependencies>
4439

4540
</project>

core-java-modules/core-java-8/src/main/java/com/wdbyte/Jdk8Lambda.java

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package com.wdbyte;
22

3-
import lombok.AllArgsConstructor;
4-
import lombok.Getter;
5-
import lombok.Setter;
6-
import lombok.ToString;
73
import org.junit.jupiter.api.Test;
84

95
import java.util.*;
@@ -70,13 +66,33 @@ public void functionLambdaTest() {
7066
}
7167

7268

73-
@Getter
74-
@Setter
75-
@ToString
76-
@AllArgsConstructor
7769
static class User {
7870
private String name;
7971
private Integer age;
72+
73+
public User() {
74+
}
75+
76+
public User(String name, Integer age) {
77+
this.name = name;
78+
this.age = age;
79+
}
80+
81+
public String getName() {
82+
return name;
83+
}
84+
85+
public void setName(String name) {
86+
this.name = name;
87+
}
88+
89+
public Integer getAge() {
90+
return age;
91+
}
92+
93+
public void setAge(Integer age) {
94+
this.age = age;
95+
}
8096
}
8197

8298
public static List<User> userList = new ArrayList<User>();

core-java-modules/core-java-8/src/main/java/com/wdbyte/Jdk8Optional.java

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
import java.util.Optional;
44

5-
6-
import lombok.Data;
75
import org.junit.jupiter.api.Test;
86

97
/**
@@ -182,23 +180,44 @@ public void optionalTest() {
182180
/**
183181
* 计算机
184182
*/
185-
@Data
186183
class Computer {
187184
private Optional<SoundCard> soundCard;
185+
186+
public Optional<SoundCard> getSoundCard() {
187+
return soundCard;
188+
}
189+
190+
public void setSoundCard(Optional<SoundCard> soundCard) {
191+
this.soundCard = soundCard;
192+
}
188193
}
189194

190195
/**
191196
* 声卡
192197
*/
193-
@Data
194198
class SoundCard {
195199
private Optional<Usb> usb;
200+
201+
public Optional<Usb> getUsb() {
202+
return usb;
203+
}
204+
205+
public void setUsb(Optional<Usb> usb) {
206+
this.usb = usb;
207+
}
196208
}
197209

198210
/**
199211
* USB
200212
*/
201-
@Data
202213
class Usb {
203214
private String version;
215+
216+
public String getVersion() {
217+
return version;
218+
}
219+
220+
public void setVersion(String version) {
221+
this.version = version;
222+
}
204223
}

pom.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,5 @@
4545
<artifactId>commons-lang3</artifactId>
4646
<version>${commons-lang3.version}</version>
4747
</dependency>
48-
<dependency>
49-
<groupId>org.projectlombok</groupId>
50-
<artifactId>lombok</artifactId>
51-
<version>${lombok.version}</version>
52-
</dependency>
5348
</dependencies>
5449
</project>

tool-java-jackson/src/main/java/com/wdbyte/jackson/Cat.java

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
package com.wdbyte.jackson;
22

33
import com.fasterxml.jackson.annotation.JsonGetter;
4-
import com.fasterxml.jackson.annotation.JsonIgnore;
54
import com.fasterxml.jackson.annotation.JsonSetter;
6-
import lombok.Data;
75

86
/**
97
* @author https://www.wdbyte.com
108
* @date 2022/07/17
119
*/
12-
@Data
1310
public class Cat {
1411

1512
@JsonSetter(value = "catName")
@@ -21,4 +18,24 @@ public class Cat {
2118
public String getName() {
2219
return name;
2320
}
21+
22+
public void setName(String name) {
23+
this.name = name;
24+
}
25+
26+
public Integer getAge() {
27+
return age;
28+
}
29+
30+
public void setAge(Integer age) {
31+
this.age = age;
32+
}
33+
34+
public Cat() {
35+
}
36+
37+
public Cat(String name, Integer age) {
38+
this.name = name;
39+
this.age = age;
40+
}
2441
}

tool-java-jackson/src/main/java/com/wdbyte/jackson/Order.java

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,15 @@
11
package com.wdbyte.jackson;
22

3-
import java.time.LocalDateTime;
4-
import java.util.Date;
5-
63
import com.fasterxml.jackson.annotation.JsonFormat;
7-
import com.fasterxml.jackson.annotation.JsonGetter;
84
import com.fasterxml.jackson.annotation.JsonSetter;
9-
import lombok.AllArgsConstructor;
10-
import lombok.Data;
11-
import lombok.NoArgsConstructor;
12-
import lombok.ToString;
5+
6+
import java.time.LocalDateTime;
7+
import java.util.Date;
138

149
/**
1510
* @author https://www.wdbyte.com
1611
* @date 2022/07/17
1712
*/
18-
//@Data
19-
@AllArgsConstructor
20-
@NoArgsConstructor
21-
@ToString
2213
public class Order {
2314

2415
@JsonSetter(value = "orderId")
@@ -54,4 +45,22 @@ public LocalDateTime getUpdateTime() {
5445
public void setUpdateTime(LocalDateTime updateTime) {
5546
this.updateTime = updateTime;
5647
}
48+
49+
@Override
50+
public String toString() {
51+
return "Order{" +
52+
"id=" + id +
53+
", createTime=" + createTime +
54+
", updateTime=" + updateTime +
55+
'}';
56+
}
57+
58+
public Order() {
59+
}
60+
61+
public Order(Integer id, Date createTime, LocalDateTime updateTime) {
62+
this.id = id;
63+
this.createTime = createTime;
64+
this.updateTime = updateTime;
65+
}
5766
}

tool-java-jackson/src/main/java/com/wdbyte/jackson/Person.java

Lines changed: 42 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,55 @@
22

33
import java.util.List;
44

5-
import lombok.Data;
6-
75
/**
86
* @author https://www.wdbyte.com
97
* @date 2022/07/16
108
*/
11-
@Data
129
public class Person {
1310
private String name;
1411
private Integer age;
1512
private List<String> skillList;
13+
14+
@Override
15+
public String toString() {
16+
return "Person{" +
17+
"name='" + name + '\'' +
18+
", age=" + age +
19+
", skillList=" + skillList +
20+
'}';
21+
}
22+
23+
public Person(String name, Integer age, List<String> skillList) {
24+
this.name = name;
25+
this.age = age;
26+
this.skillList = skillList;
27+
}
28+
29+
public Person() {
30+
}
31+
32+
public String getName() {
33+
return name;
34+
}
35+
36+
public void setName(String name) {
37+
this.name = name;
38+
}
39+
40+
public Integer getAge() {
41+
return age;
42+
}
43+
44+
public void setAge(Integer age) {
45+
this.age = age;
46+
}
47+
48+
public List<String> getSkillList() {
49+
return skillList;
50+
}
51+
52+
public void setSkillList(List<String> skillList) {
53+
this.skillList = skillList;
54+
}
1655
}
1756

0 commit comments

Comments
 (0)