A person. @author Alex Ruiz
| 18 | * @author Alex Ruiz |
| 19 | */ |
| 20 | public class Person implements Comparable<Person> { |
| 21 | |
| 22 | private final String name; |
| 23 | |
| 24 | public Person(String name) { |
| 25 | this.name = name; |
| 26 | } |
| 27 | |
| 28 | public String getName() { |
| 29 | return name; |
| 30 | } |
| 31 | |
| 32 | @Override |
| 33 | public int hashCode() { |
| 34 | final int prime = 31; |
| 35 | int result = 1; |
| 36 | result = prime * result + ((name == null) ? 0 : name.hashCode()); |
| 37 | return result; |
| 38 | } |
| 39 | |
| 40 | @Override |
| 41 | public boolean equals(Object obj) { |
| 42 | if (this == obj) return true; |
| 43 | if (obj == null) return false; |
| 44 | if (getClass() != obj.getClass()) return false; |
| 45 | Person other = (Person) obj; |
| 46 | if (name == null) { |
| 47 | if (other.name != null) return false; |
| 48 | } else if (!name.equals(other.name)) return false; |
| 49 | return true; |
| 50 | } |
| 51 | |
| 52 | @Override |
| 53 | public int compareTo(Person other) { |
| 54 | return name.compareTo(other.name); |
| 55 | } |
| 56 | |
| 57 | @Override |
| 58 | public String toString() { |
| 59 | return String.format("Person[name='%s']", name); |
| 60 | } |
| 61 | } |
nothing calls this directly
no outgoing calls
no test coverage detected