File tree Expand file tree Collapse file tree 1 file changed +40
-0
lines changed
exercises/concept/tim-from-marketing-2/.meta/src/reference/java Expand file tree Collapse file tree 1 file changed +40
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments