/
javapractice
/
JavaPractice
Обзор
Документация
Войти
/
javapractice
/
JavaPractice
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
2
CI/CD
Аналитика
develop
ApachePOI/src/main/java/entities/Owner.java
131 строка
3 KB
Zexa91x0
Apache POI - CompareTO for entities
22 май 2021, 11:07
22 май 2021, 11:07
af5ee33
Код
Авторство
О чём код?
package entities; import org.jetbrains.annotations.NotNull; import java.util.Objects; public class Owner implements Comparable<Owner>{ private String id; private String nameFirst; private String nameLast; private String comment; private Department department; private String mail; private Integer limit; public Owner(String id, String nameFirst, String nameLast) { this.id = id; this.nameFirst = nameFirst; this.nameLast = nameLast; } public Owner(String comment) { this.comment = comment; } public Owner(String id, String nameFirst, String nameLast, String comment, Department department, String eMail, int limit) { this.id = id; this.nameFirst = nameFirst; this.nameLast = nameLast; this.comment = comment; this.department = department; this.mail = eMail; this.limit = limit; } public Department getDepartment() { return department; } public Owner setDepartment(Department department) { this.department = department; return this; } public int getLimit() { return limit; } public Owner setLimit(int limit) { this.limit = limit; return this; } public String getId() { return id; } public Owner setId(String id) { this.id = id; return this; } public String getNameFirst() { return nameFirst; } public Owner setNameFirst(String nameFirst) { this.nameFirst = nameFirst; return this; } public String getNameLast() { return nameLast; } public Owner setNameLast(String nameLast) { this.nameLast = nameLast; return this; } public String getComment() { return comment; } public Owner setComment(String comment) { this.comment = comment; return this; } public String getMail() { return mail; } public Owner setMail(String mail) { this.mail = mail; return this; } @Override public boolean equals(Object o) { if (this == o) return true; if (!(o instanceof Owner)) return false; Owner owner = (Owner) o; return Objects.equals(getComment(), owner.getComment()); } @Override public int hashCode() { return Objects.hash(getComment()); } @Override public String toString() { return nameFirst + " " + nameLast + " (" + id + ")" + ((comment == null) ? ("") : (" " + comment)) + ((department == null) ? ("") : (" " + department)) + ((mail == null) ? ("") : (" " + mail)) + ((limit == null) ? ("") : (" " + limit)); } @Override public int compareTo(@NotNull Owner o) { return this.getId().concat(this.getNameFirst() .concat(this.getNameLast() .concat(this.getComment()))) .compareTo( o.getId().concat(o.getNameFirst().concat(o.getNameLast().concat(o.getComment())))); } }