package com.baeldung.map.mergemaps; public class Employee implements Comparable { private Long id; private String name; public Employee(Long id, String name) { this.name = name; this.id = id; } public Long getId() { return id; } public void setId(Long id) { this.id = id; } public String getName() { return name; } public void setName(String name) { this.name = name; } @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; Employee employee = (Employee) o; if (!id.equals(employee.id)) return false; return name.equals(employee.name); } @Override public int hashCode() { int result = id.hashCode(); result = 31 * result + name.hashCode(); return result; } @Override public String toString() { return "Employee{" + "id=" + id + ", name='" + name + '\'' + '}'; } @Override public int compareTo(Employee employee) { return (int)(this.id - employee.getId()); } }