diff --git a/Address.java b/Address.java new file mode 100644 index 0000000..96d9056 --- /dev/null +++ b/Address.java @@ -0,0 +1,33 @@ +package com.journaldev.json.model; + + +public class Address { + + private String street; + private String city; + private int zipcode; + + public String getStreet() { + return street; + } + public void setStreet(String street) { + this.street = street; + } + public String getCity() { + return city; + } + public void setCity(String city) { + this.city = city; + } + public int getZipcode() { + return zipcode; + } + public void setZipcode(int zipcode) { + this.zipcode = zipcode; + } + + @Override + public String toString(){ + return getStreet() + ", "+getCity()+", "+getZipcode(); + } +} diff --git a/Employee.java b/Employee.java new file mode 100644 index 0000000..3bfa520 --- /dev/null +++ b/Employee.java @@ -0,0 +1,86 @@ +package com.journaldev.json.model; + +import java.util.Arrays; +import java.util.List; +import java.util.Map; + +import com.google.gson.annotations.SerializedName; + +public class Employee { + + @SerializedName("empID") + private int id; + private String name; + private boolean permanent; + private Address address; + private long[] phoneNumbers; + private String role; + private List cities; + private Map properties; + + public int getId() { + return id; + } + public void setId(int id) { + this.id = id; + } + public String getName() { + return name; + } + public void setName(String name) { + this.name = name; + } + public boolean isPermanent() { + return permanent; + } + public void setPermanent(boolean permanent) { + this.permanent = permanent; + } + public Address getAddress() { + return address; + } + public void setAddress(Address address) { + this.address = address; + } + public long[] getPhoneNumbers() { + return phoneNumbers; + } + public void setPhoneNumbers(long[] phoneNumbers) { + this.phoneNumbers = phoneNumbers; + } + public String getRole() { + return role; + } + public void setRole(String role) { + this.role = role; + } + + @Override + public String toString(){ + StringBuilder sb = new StringBuilder(); + sb.append("***** Employee Details *****\n"); + sb.append("ID="+getId()+"\n"); + sb.append("Name="+getName()+"\n"); + sb.append("Permanent="+isPermanent()+"\n"); + sb.append("Role="+getRole()+"\n"); + sb.append("Phone Numbers="+Arrays.toString(getPhoneNumbers())+"\n"); + sb.append("Address="+getAddress()+"\n"); + sb.append("Cities="+Arrays.toString(getCities().toArray())+"\n"); + sb.append("Properties="+getProperties()+"\n"); + sb.append("*****************************"); + + return sb.toString(); + } + public List getCities() { + return cities; + } + public void setCities(List cities) { + this.cities = cities; + } + public Map getProperties() { + return properties; + } + public void setProperties(Map properties) { + this.properties = properties; + } +}