-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersona.java
More file actions
95 lines (80 loc) · 1.9 KB
/
Copy pathPersona.java
File metadata and controls
95 lines (80 loc) · 1.9 KB
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
package devcode.module_08x01_App;
public class Persona implements Comparable<Persona>{
private Integer id;
private String nombre;
private Integer edad;
public Persona() {
}
public Persona(Integer id, String nombre, Integer edad) {
super();
this.id = id;
this.nombre = nombre;
this.edad = edad;
}
public Integer getId() {
return id;
}
public void setId(Integer id) {
this.id = id;
}
public String getNombre() {
return nombre;
}
public void setNombre(String nombre) {
this.nombre = nombre;
}
public Integer getEdad() {
return edad;
}
public void setEdad(Integer edad) {
this.edad = edad;
}
@Override
public String toString() {
return "Persona [id=" + id + ", nombre=" + nombre + ", edad=" + edad + "]";
}
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
result = prime * result + ((edad == null) ? 0 : edad.hashCode());
result = prime * result + ((id == null) ? 0 : id.hashCode());
result = prime * result + ((nombre == null) ? 0 : nombre.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;
Persona other = (Persona) obj;
if (edad == null) {
if (other.edad != null)
return false;
} else if (!edad.equals(other.edad))
return false;
if (id == null) {
if (other.id != null)
return false;
} else if (!id.equals(other.id))
return false;
if (nombre == null) {
if (other.nombre != null)
return false;
} else if (!nombre.equals(other.nombre))
return false;
return true;
}
@Override
public int compareTo(Persona per) {
if (this.compareTo(per) < 0 )
return -1;
else if (this.compareTo(per) > 0 )
return 1;
else
return 0;
}
}