Skip to content

Instantly share code, notes, and snippets.

@kpradeep12
Created April 4, 2018 02:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kpradeep12/b534f331e76a9e1344d2b07836c0150a to your computer and use it in GitHub Desktop.
Save kpradeep12/b534f331e76a9e1344d2b07836c0150a to your computer and use it in GitHub Desktop.
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