Created
April 4, 2018 02:28
-
-
Save kpradeep12/b534f331e76a9e1344d2b07836c0150a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Employee{ | |
private Integer id; | |
private String name; | |
private Integer age; | |
Employee(Integer id, String name, Integer age) { | |
this.id = id; | |
this.name = name; | |
this.age = age; | |
} | |
public Integer getId() { return id; } | |
public String getName() { return name; } | |
public Integer getAge() { return age; } | |
@Override | |
public String toString() { | |
return "Employee{ id=" + id + | |
", name='" + name + '\'' + | |
", age=" + age + '}'; | |
} | |
} | |
public class EmployeeService { | |
Map<Integer, Employee> store = Map.of(1, new Employee(1, "Peter", 34), | |
2, new Employee(2, "John", 28), | |
3, new Employee(3, "Bill", 42)); | |
Optional<Employee> getEmployee(Integer id){ | |
return Optional.ofNullable(store.get(id)); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment