Skip to content

Commit 5c143e1

Browse files
committed
exercises/concept/tim-from-marketing-2/
1 parent 0abf443 commit 5c143e1

File tree

1 file changed

+40
-0
lines changed
  • exercises/concept/tim-from-marketing-2/.meta/src/reference/java

1 file changed

+40
-0
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import java.util.Objects;
2+
import java.util.Optional;
3+
4+
class Employee {
5+
private final int id;
6+
private final String name;
7+
private final String department;
8+
9+
public Employee(int id, String name, String department) {
10+
this.id = id;
11+
this.name = name;
12+
this.department = department;
13+
}
14+
15+
public Optional<Integer> getNullableId() {
16+
return Optional.ofNullable(id);
17+
}
18+
19+
public Optional<String> getNullableName() {
20+
return Optional.ofNullable(name);
21+
}
22+
23+
public Optional<String> getNullableDepartment() {
24+
return Optional.ofNullable(department);
25+
}
26+
27+
@Override
28+
public boolean equals(Object o) {
29+
if (this == o) return true;
30+
if (o == null || getClass() != o.getClass()) return false;
31+
Employee employee = (Employee) o;
32+
return id == employee.id &&
33+
Objects.equals(name, employee.name) && Objects.equals(department, employee.department);
34+
}
35+
36+
@Override
37+
public int hashCode() {
38+
return Objects.hash(id, name, department);
39+
}
40+
}

0 commit comments

Comments
 (0)