-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathCustomKey.java
More file actions
45 lines (41 loc) · 943 Bytes
/
CustomKey.java
File metadata and controls
45 lines (41 loc) · 943 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
package StudentClass;
public class CustomKey
{
private long id;
private String name;
public CustomKey(final Student student)
{
this.id = student.getID();
this.name = student.getName();
}
@Override
public int hashCode()
{
final int prime = 31;
int result = 1;
result = prime * result + (int) (id ^ (id >>> 32));
result = prime * result + ((name == null) ? 0 : name.hashCode());
return result;
}
@Override
public boolean equals(Object obj)
{
if (this == obj)
return true;
if (obj == null)
return false;
if (getClass() != obj.getClass())
return false;
CustomKey other = (CustomKey) obj;
if (id != other.id)
return false;
if (name == null)
{
if (other.name != null)
return false;
}
else if (!name.equals(other.name))
return false;
return true;
}
}