Skip to content

Commit 97945fd

Browse files
committed
Lombok dependency implemented
1 parent ffdad46 commit 97945fd

File tree

3 files changed

+18
-57
lines changed

3 files changed

+18
-57
lines changed

Readme.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,2 @@
1-
# SAVE API
2-
- saveDepartment method en Controller (@PostMapping()) ->
3-
- Service ->
4-
- DepartmentRepository.save(department)
1+
# LOMBOK
2+
- Data classes - sin necesidad de añadir getter / setters, constructors, toString...

pom.xml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,13 @@
5151
<artifactId>spring-boot-starter-data-jpa</artifactId>
5252
<version>2.7.1</version>
5353
</dependency>
54+
<!-- https://mvnrepository.com/artifact/org.projectlombok/lombok -->
55+
<dependency>
56+
<groupId>org.projectlombok</groupId>
57+
<artifactId>lombok</artifactId>
58+
<version>1.18.24</version>
59+
<scope>provided</scope>
60+
</dependency>
5461

5562
</dependencies>
5663

Lines changed: 9 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,21 @@
11
package com.example.springbootapirest.entity;
22

3-
import org.hibernate.validator.constraints.Length;
3+
import lombok.AllArgsConstructor;
4+
import lombok.Builder;
5+
import lombok.Data;
6+
import lombok.NoArgsConstructor;
47

58
import javax.persistence.Entity;
69
import javax.persistence.GeneratedValue;
710
import javax.persistence.GenerationType;
811
import javax.persistence.Id;
9-
import javax.validation.constraints.*;
12+
import javax.validation.constraints.NotBlank;
1013

1114
@Entity
15+
@Data
16+
@NoArgsConstructor
17+
@AllArgsConstructor
18+
@Builder
1219
public class Department {
1320

1421
@Id
@@ -28,56 +35,5 @@ public class Department {
2835
private String departmentAddress;
2936
private String departmentCode;
3037

31-
public Department() {
32-
}
3338

34-
public Department(Long departmentId, String departmentName, String departmentAddress, String departmentCode) {
35-
this.departmentId = departmentId;
36-
this.departmentName = departmentName;
37-
this.departmentAddress = departmentAddress;
38-
this.departmentCode = departmentCode;
39-
}
40-
41-
@Override
42-
public String toString() {
43-
final StringBuffer sb = new StringBuffer("Department{");
44-
sb.append("departmentId=").append(departmentId);
45-
sb.append(", departmentName='").append(departmentName).append('\'');
46-
sb.append(", departmentAddress='").append(departmentAddress).append('\'');
47-
sb.append(", departmentCode='").append(departmentCode).append('\'');
48-
sb.append('}');
49-
return sb.toString();
50-
}
51-
52-
public Long getDepartmentId() {
53-
return departmentId;
54-
}
55-
56-
public void setDepartmentId(Long departmentId) {
57-
this.departmentId = departmentId;
58-
}
59-
60-
public String getDepartmentName() {
61-
return departmentName;
62-
}
63-
64-
public void setDepartmentName(String departmentName) {
65-
this.departmentName = departmentName;
66-
}
67-
68-
public String getDepartmentAddress() {
69-
return departmentAddress;
70-
}
71-
72-
public void setDepartmentAddress(String departmentAddress) {
73-
this.departmentAddress = departmentAddress;
74-
}
75-
76-
public String getDepartmentCode() {
77-
return departmentCode;
78-
}
79-
80-
public void setDepartmentCode(String departmentCode) {
81-
this.departmentCode = departmentCode;
82-
}
8339
}

0 commit comments

Comments
 (0)