Back to project page Joetz-Android-V2.
The source code is released under:
GNU General Public License
If you think the Android project Joetz-Android-V2 listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.example.jens.myapplication.domain; //from www .ja v a 2 s . co m import android.os.Parcel; import android.os.Parcelable; import com.example.jens.myapplication.domain.converter.UnixDateTimeConverter; import com.fasterxml.jackson.annotation.JsonFilter; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import org.joda.time.DateTime; /** * Created by Sam on 21/10/2014. */ /** * JsonIgnoreProperties(ignoreUnknown = true) indicates that while converting the JSON string from * the server to a User object, fields not defined here will be ignored instead of * throwing an error. */ @JsonIgnoreProperties(ignoreUnknown = true) public class Person implements Parcelable { public static final String JSON_ID = "Id"; public static final String JSON_FIRST_NAME = "Firstname"; public static final String JSON_LAST_NAME = "Lastname"; public static final String JSON_EMAIL = "Email"; public static final String JSON_DATE_OF_BIRTH = "DateOfBirth"; public static final String JSON_STREET = "Street"; public static final String JSON_HOUSE_NUMBER = "HouseNumber"; public static final String JSON_BUS = "Bus"; public static final String JSON_POSTAL_CODE = "PostalCode"; public static final String JSON_CITY = "City"; public static final String JSON_TELEPHONE = "Telephone"; public static final String JSON_RIJKSREGISTERNUMMER = "RijksregisterNummer"; public static final String JSON_BOND_AANSLUITINGSNUMMER = "AansluitingsNummer"; public static final String JSON_BOND_CODE_GERECHTIGDE = "CodeGerechtigde"; public static final String JSON_SUBSCRIBED_TO_NEWSLETTER = "SubscribedToNewsletter"; @JsonProperty(JSON_ID) private long id = -1; @JsonProperty(JSON_FIRST_NAME) private String firstName; @JsonProperty(JSON_LAST_NAME) private String lastName; @JsonProperty(JSON_EMAIL) private String email; //Separate getter/setter for unix conversion. @JsonIgnore private DateTime dateOfBirth; @JsonProperty(JSON_STREET) private String street; @JsonProperty(JSON_HOUSE_NUMBER) private int houseNumber; @JsonProperty(JSON_BUS) private String bus; @JsonProperty(JSON_POSTAL_CODE) private int postalCode; @JsonProperty(JSON_CITY) private String city; @JsonProperty(JSON_TELEPHONE) private String phone; @JsonProperty(JSON_RIJKSREGISTERNUMMER) private String rijksRegisterNummer; @JsonProperty(JSON_BOND_AANSLUITINGSNUMMER) private String bondAansluitingsNr; @JsonProperty(JSON_BOND_CODE_GERECHTIGDE) private String bondCodeGerechtigde; public Person(){ } public boolean hasBondInformation(){ return this.getBondAansluitingsNr() != null && !this.getBondAansluitingsNr().isEmpty() && this.getBondCodeGerechtigde() != null && !this.getBondCodeGerechtigde().isEmpty(); } public String getEmail() { return email; } public void setEmail(String email) { this.email = email; } 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 DateTime getDateOfBirth() { return dateOfBirth; } public void setDateOfBirth(DateTime dateOfBirth) { this.dateOfBirth = dateOfBirth; } @JsonProperty(JSON_DATE_OF_BIRTH) public long getUnixDateOfBirth(){ return UnixDateTimeConverter.getUnix(dateOfBirth); } @JsonProperty(JSON_DATE_OF_BIRTH) public void setUnixDateOfBirth(long unixTime){ setDateOfBirth(UnixDateTimeConverter.getDate(unixTime)); } public String getStreet() { return street; } public void setStreet(String street) { this.street = street; } public int getPostalCode() { return postalCode; } public void setPostalCode(int postalCode) { this.postalCode = postalCode; } public String getCity() { return city; } public void setCity(String city) { this.city = city; } public String getPhone() { return phone; } public void setPhone(String phone) { this.phone = phone; } public String getRijksRegisterNummer() { return rijksRegisterNummer; } public void setRijksRegisterNummer(String rijksRegisterNummer) { this.rijksRegisterNummer = rijksRegisterNummer; } public String getBondCodeGerechtigde() { return bondCodeGerechtigde; } public void setBondCodeGerechtigde(String bondCodeGerechtigde) { this.bondCodeGerechtigde = bondCodeGerechtigde; } public String getBondAansluitingsNr() { return bondAansluitingsNr; } public void setBondAansluitingsNr(String bondAansluitingsNr) { this.bondAansluitingsNr = bondAansluitingsNr; } public int getHouseNumber() { return houseNumber; } public void setHouseNumber(int houseNumber) { this.houseNumber = houseNumber; } public String getBus() { return bus; } public void setBus(String bus) { this.bus = bus; } public long getId() { return id; } public void setId(long id) { this.id = id; } /** * Creates a clone of this person, returns a new person with the same data * @return */ public Person clone(){ Person p = new Person(); p.setId(getId()); p.setFirstName(getFirstName()); p.setLastName(getLastName()); p.setEmail(getEmail()); p.setDateOfBirth(getDateOfBirth()); p.setStreet(getStreet()); p.setHouseNumber(getHouseNumber()); p.setBus(getBus()); p.setPostalCode(getPostalCode()); p.setCity(getCity()); p.setPhone(getPhone()); p.setRijksRegisterNummer(getRijksRegisterNummer()); p.setBondAansluitingsNr(getBondAansluitingsNr()); p.setBondCodeGerechtigde(getBondCodeGerechtigde()); return p; } @Override public String toString() { return "Person[Name: " + firstName + " " + lastName + " || Email: " + email + "]"; } //Parcelable area @Override public int describeContents() { return 0; } @Override public void writeToParcel(Parcel pc, int flags) { pc.writeLong(id); pc.writeString(firstName); pc.writeString(lastName); pc.writeString(email); pc.writeLong(getUnixDateOfBirth()); pc.writeString(street); pc.writeInt(houseNumber); pc.writeString(bus); pc.writeInt(postalCode); pc.writeString(city); pc.writeString(phone); pc.writeString(rijksRegisterNummer); pc.writeString(bondAansluitingsNr); pc.writeString(bondCodeGerechtigde); } public static final Parcelable.Creator<Person> CREATOR = new Parcelable.Creator<Person>(){ @Override public Person createFromParcel(Parcel source) { return new Person(source); } @Override public Person[] newArray(int size) { return new Person[size]; } }; public Person(Parcel pc){ id = pc.readLong(); firstName = pc.readString(); lastName = pc.readString(); email = pc.readString(); setUnixDateOfBirth(pc.readLong()); street = pc.readString(); houseNumber = pc.readInt(); bus = pc.readString(); postalCode = pc.readInt(); city = pc.readString(); phone = pc.readString(); rijksRegisterNummer = pc.readString(); bondAansluitingsNr = pc.readString(); bondCodeGerechtigde = pc.readString(); } }