0% found this document useful (0 votes)
5 views

Scribd

Uploaded by

singhshaivya0505
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

Scribd

Uploaded by

singhshaivya0505
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

//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) {

You might also like