From 14f2b7c2b85426f31ba88e9a30a8ec7dd62f2260 Mon Sep 17 00:00:00 2001 From: Mayank Aggarwal Date: Tue, 15 Mar 2022 22:14:34 +0530 Subject: [PATCH] [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 --- .../com/baeldung/employee/EmployeeBean.java | 48 ++++++++++++++++++ .../com/baeldung/employee/EmployeeDTO.java | 34 +++++++++++++ .../com/baeldung/employee/EmployeePOJO.java | 49 +++++++++++++++++++ .../com/baeldung/employee/EmployeeVO.java | 40 +++++++++++++++ 4 files changed, 171 insertions(+) create mode 100644 core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeBean.java create mode 100644 core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeDTO.java create mode 100644 core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeePOJO.java create mode 100644 core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeVO.java diff --git a/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeBean.java b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeBean.java new file mode 100644 index 0000000000..ed75a7157c --- /dev/null +++ b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeBean.java @@ -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; + } + +} diff --git a/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeDTO.java b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeDTO.java new file mode 100644 index 0000000000..beb6bf3ce5 --- /dev/null +++ b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeDTO.java @@ -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; + } +} diff --git a/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeePOJO.java b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeePOJO.java new file mode 100644 index 0000000000..50f17d965f --- /dev/null +++ b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeePOJO.java @@ -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; + } +} \ No newline at end of file diff --git a/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeVO.java b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeVO.java new file mode 100644 index 0000000000..7a1775f79d --- /dev/null +++ b/core-java-modules/core-java-lang-4/src/main/java/com/baeldung/employee/EmployeeVO.java @@ -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); + } +}