Skip to content

Commit

Permalink
#24 Agent#salutation, lombok
Browse files Browse the repository at this point in the history
  • Loading branch information
mike-podolskiy90 committed Apr 24, 2024
1 parent 6c94db8 commit 1b26e87
Showing 1 changed file with 16 additions and 116 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,47 +16,43 @@
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.StringJoiner;

import org.apache.commons.lang3.StringUtils;

import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

/**
* Encapsulates all the information for an Agent.
*/
@Setter
@EqualsAndHashCode
@ToString
public class Agent implements Serializable {

private static final long serialVersionUID = 7028536657833651816L;

@Getter
private String salutation;
private String firstName;
private String lastName;
private String organisation;
private String position;
// TODO: rename fields, phone -> phones etc. ???
// TODO: use lombok where possible?
@Getter
private Address address = new Address();
@Getter
private List<String> phone = new ArrayList<>();
@Getter
private List<String> email = new ArrayList<>();
@Getter
private String role;
@Getter
private List<String> homepage = new ArrayList<>();
@Getter
private List<UserId> userIds = new ArrayList<>();

public Address getAddress() {
return address;
}

public void setAddress(Address address) {
this.address = address;
}

public List<String> getEmail() {
return email;
}

public void setEmail(List<String> email) {
this.email = email;
}

public void addEmail(String email) {
this.email.add(email);
}
Expand All @@ -68,18 +64,6 @@ public String getFirstName() {
return firstName;
}

public void setFirstName(String firstName) {
this.firstName = firstName;
}

public List<String> getHomepage() {
return homepage;
}

public void setHomepage(List<String> homepage) {
this.homepage = homepage;
}

public void addHomepage(String homepage) {
this.homepage.add(homepage);
}
Expand All @@ -91,29 +75,13 @@ public String getLastName() {
return lastName;
}

public void setLastName(String lastName) {
this.lastName = lastName;
}

public String getOrganisation() {
if (organisation == null || organisation.isEmpty()) {
return null;
}
return organisation;
}

public void setOrganisation(String organisation) {
this.organisation = organisation;
}

public List<String> getPhone() {
return phone;
}

public void setPhone(List<String> phone) {
this.phone = phone;
}

public void addPhone(String phone) {
this.phone.add(phone);
}
Expand All @@ -125,26 +93,6 @@ public String getPosition() {
return position;
}

public void setPosition(String position) {
this.position = position;
}

public List<UserId> getUserIds() {
return userIds;
}

public void setUserIds(List<UserId> userIds) {
this.userIds = userIds;
}

public String getRole() {
return role;
}

public void setRole(String role) {
this.role = role;
}

public String getFullName() {
String name = "";
if (firstName != null && !firstName.isEmpty()) {
Expand Down Expand Up @@ -173,52 +121,4 @@ public boolean isEmpty() {
&& address.isEmpty()
&& userIds.isEmpty();
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
Agent agent = (Agent) o;
return Objects.equals(firstName, agent.firstName)
&& Objects.equals(lastName, agent.lastName)
&& Objects.equals(organisation, agent.organisation)
&& Objects.equals(position, agent.position)
&& Objects.equals(address, agent.address)
&& Objects.equals(phone, agent.phone)
&& Objects.equals(email, agent.email)
&& Objects.equals(role, agent.role)
&& Objects.equals(homepage, agent.homepage)
&& Objects.equals(userIds, agent.userIds);
}

@Override
public int hashCode() {
return Objects.hash(
firstName,
lastName,
organisation,
position,
address,
phone,
email,
role,
homepage,
userIds);
}

@Override
public String toString() {
return new StringJoiner(", ", Agent.class.getSimpleName() + "[", "]")
.add("firstName='" + firstName + "'")
.add("lastName='" + lastName + "'")
.add("organisation='" + organisation + "'")
.add("position='" + position + "'")
.add("address=" + address)
.add("phone='" + phone + "'")
.add("email='" + email + "'")
.add("role='" + role + "'")
.add("homepage='" + homepage + "'")
.add("userIds=" + userIds)
.toString();
}
}

0 comments on commit 1b26e87

Please sign in to comment.