Entity Class - JobFinder Application

In the application JobFinder we have one model class named Visitor.java which consists of several required fields on the basis of our business plan along with their getters, setters, toString function and constructors.

public class Visitor {

@NotNull(message="is required")

@Size(message="is required", min=1)

private String firstName;

private String lastName;

private String city;

private LinkedHashMap<String, String> cityOptions;

private String relocate;

private String[] languagesKnown;

@ConCode

private String conCode;

Above are all the fields declared.


public Visitor(){

//populate country options

cityOptions = new LinkedHashMap<>();

cityOptions.put("BOB", "Mumbai");

cityOptions.put("IDR", "Indore");

cityOptions.put("DL", "Delhi");

cityOptions.put("MAS", "Chennai");

cityOptions.put("BR", "Banglore");

}

public Visitor(String firstName, String lastName, String city, LinkedHashMap<String, String> cityOptions,

String relocate, String[] languagesKnown) {

this.firstName = firstName;

this.lastName = lastName;

this.city = city;

this.cityOptions = cityOptions;

this.relocate = relocate;

this.languagesKnown = languagesKnown;

}

Above are two constructors we have defined.


@Override

public String toString() {

return "Visitor [firstName=" + firstName + ", lastName=" + lastName + ", city=" + city + ", cityOptions="

+ cityOptions + ", relocate=" + relocate + ", languagesKnown=" + Arrays.toString(languagesKnown) + "]";

}

Above is the toString() which will return a string representation of an object.

public String getFirstName() {

return firstName;

}

public void setFirstName(String firstName) {

this.firstName = firstName;

}

public String getLastName() {

return lastName;

}

public void setLastName(String lastName) {

this.lastName = lastName;

}

public String getCity() {

return city;

}

public void setCity(String city) {

this.city = city;

}

public LinkedHashMap<String, String> getCityOptions() {

return cityOptions;

}

public void setCityOptions(LinkedHashMap<String, String> cityOptions) {

this.cityOptions = cityOptions;

}

public String getRelocate() {

return relocate;

}

public void setRelocate(String relocate) {

this.relocate = relocate;

}

public String[] getLanguagesKnown() {

return languagesKnown;

}

public void setLanguagesKnown(String[] languagesKnown) {

this.languagesKnown = languagesKnown;

}

public String getConCode() {

return conCode;

}

public void setConCode(String conCode) {

this.conCode = conCode;

}

Above are the getters() and setters() methods which play a vital role as they get invoked by the controller Model Attribute to take data for the processing of application.


Go to next steps:-

jsp files and Controller Classes

Comments

Popular posts from this blog

Depression-A life taking mind disorder

Benefits of Giloy or Tinospora