Skip to content

Method: hashCode()

1: package migration.difffile.objects;
2:
3: public class DiffIdentifier {
4:         /**
5:          * the name of Difference.
6:          */
7:         final String name;
8:
9:         public DiffIdentifier(String name) {
10:                 super();
11:                 this.name = name;
12:         }
13:
14:         /**
15:          * @return the name
16:          */
17:         public String getName() {
18:                 return name;
19:         }
20:
21:         @Override
22:         public String toString() {
23:                 return "DiffIdentifier [name=" + name + "]";
24:         }
25:
26:         @Override
27:         public int hashCode() {
28:                 final int prime = 31;
29:                 int result = 1;
30:•                result = prime * result + ((name == null)
31:                                 ? 0
32:                                 : name.hashCode());
33:                 return result;
34:         }
35:
36:         @Override
37:         public boolean equals(final Object obj) {
38:                 if (this == obj) {
39:                         return true;
40:                 }
41:                 if (obj == null) {
42:                         return false;
43:                 }
44:                 if (getClass() != obj.getClass()) {
45:                         return false;
46:                 }
47:                 final DiffIdentifier other = (DiffIdentifier) obj;
48:                 if (name == null) {
49:                         if (other.name != null) {
50:                                 return false;
51:                         }
52:                 } else if (!name.equals(other.name)) {
53:                         return false;
54:                 }
55:                 return true;
56:         }
57:
58: }