[BAEL-5420] Added value object creation (#11901)

* [BAEL-5420] Added value object creation

* BAEL-5420 Added JavaBean and DTO classes

* [BAEL-5420] Indented the code

* Renamed EmployeePojo to EmployeePOJO

* BAEL-5420: Renamed to EmployeeDTO

* [BAEL-5420] Resolving Review comments

Co-authored-by: Mayank Agarwal <mayankaggarwal@zeta.tech>
This commit is contained in:
Mayank Aggarwal 2022-03-15 22:14:34 +05:30 committed by GitHub
parent a2dbf5d892
commit 14f2b7c2b8
4 changed files with 171 additions and 0 deletions

View File

@ -0,0 +1,48 @@
package com.baeldung.employee;
import java.io.Serializable;
import java.time.LocalDate;
public class EmployeeBean implements Serializable {
private static final long serialVersionUID = -3760445487636086034L;
private String firstName;
private String lastName;
private LocalDate startDate;
public EmployeeBean() {
}
public EmployeeBean(String firstName, String lastName, LocalDate startDate) {
this.firstName = firstName;
this.lastName = lastName;
this.startDate = startDate;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public LocalDate getStartDate() {
return startDate;
}
public void setStartDate(LocalDate startDate) {
this.startDate = startDate;
}
}

View File

@ -0,0 +1,34 @@
package com.baeldung.employee;
import java.time.LocalDate;
public class EmployeeDTO {
private String firstName;
private String lastName;
private LocalDate startDate;
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public LocalDate getStartDate() {
return startDate;
}
public void setStartDate(LocalDate startDate) {
this.startDate = startDate;
}
}

View File

@ -0,0 +1,49 @@
package com.baeldung.employee;
import java.time.LocalDate;
import java.util.Objects;
public class EmployeePOJO {
private String firstName;
private String lastName;
private LocalDate startDate;
public EmployeePOJO(String firstName, String lastName, LocalDate startDate) {
this.firstName = firstName;
this.lastName = lastName;
this.startDate = startDate;
}
public String name() {
return this.firstName + " " + this.lastName;
}
public LocalDate getStart() {
return this.startDate;
}
public String getFirstName() {
return firstName;
}
public void setFirstName(String firstName) {
this.firstName = firstName;
}
public String getLastName() {
return lastName;
}
public void setLastName(String lastName) {
this.lastName = lastName;
}
public LocalDate getStartDate() {
return startDate;
}
public void setStartDate(LocalDate startDate) {
this.startDate = startDate;
}
}

View File

@ -0,0 +1,40 @@
package com.baeldung.employee;
import java.time.LocalDate;
import java.util.Objects;
public class EmployeeVO {
private String firstName;
private String lastName;
private LocalDate startDate;
public EmployeeVO(String firstName, String lastName, LocalDate startDate) {
this.firstName = firstName;
this.lastName = lastName;
this.startDate = startDate;
}
public String getFirstName() {
return firstName;
}
public String getLastName() {
return lastName;
}
public LocalDate getStartDate() {
return startDate;
}
@Override
public boolean equals(Object obj) {
return Objects.equals(firstName, this.firstName)
&& Objects.equals(lastName, this.lastName)
&& Objects.equals(startDate, this.startDate);
}
@Override
public int hashCode() {
return Objects.hash(firstName, lastName, startDate);
}
}