//Immutable class
final class Employee{
private final String empName;
private final int empId;
private final Map<String, String> metadata;
public Employee(String empName, int empId, Map<String, String>
metadata) {
this.empName = empName;
this.empId = empId;
Map<String, String> tempData = new HashMap<>();
for(Map.Entry<String, String> e: metadata.entySet()) {
tempData.put(e.getKey(), e.getValue());
this.metadata = tempData;
public String getEmpName() {
return empName;
public int getEmpId() {
return empId;
public Map<String, String> getMetadata() {
Map<String, String> tempData = new HashMap<>();
for(Map.Entry<String, String> e: this.metadata.entySet()) {
tempData.put(e.getKey(), e.getValue());
return tempData;
//Singleton Class
class Employee {
private static Employee emp = null;
private Employee() {}
public static Employee getInstance() {
if (emp == null) {
emp = new Employee();
return emp;
@RestController
class EmployeeController {
@GetMapping()
Employee getEmployeeData(@RequestParam empId) {