Subversion Repositories SmartDukaan

Rev

Rev 35030 | View as "text/plain" | Blame | Compare with Previous | Last modification | View Log | RSS feed


package com.spice.profitmandi.common.model;

import com.fasterxml.jackson.annotation.JsonProperty;

public class CustomAddress {

        @JsonProperty(required=false)
        private int id;
    private String name;
    private String lastName;
    private String line1;
    private String line2;
    private String landmark;
    private String city;
    private String state;
    private String pinCode;
    private String country;
    private String phoneNumber;
        private Boolean isDefaultAddress;

    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 String getLine1() {
        return line1;
    }

    public void setLine1(String line1) {
        this.line1 = line1;
    }

    public String getLine2() {
        return line2;
    }

    public void setLine2(String line2) {
        this.line2 = line2;
    }

    public String getLandmark() {
        return landmark;
    }

    public void setLandmark(String landmark) {
        this.landmark = landmark;
    }

    public String getCity() {
        return city;
    }

    public void setCity(String city) {
        this.city = city;
    }

    public String getState() {
        return state;
    }

    public void setState(String state) {
        this.state = state;
    }

    public String getPinCode() {
        return pinCode;
    }

    public void setPinCode(String pinCode) {
        this.pinCode = pinCode;
    }

    public String getCountry() {
        return country;
    }

    public void setCountry(String country) {
        this.country = country;
    }

    public String getPhoneNumber() {
        return phoneNumber;
    }

    public void setPhoneNumber(String phoneNumber) {
        this.phoneNumber = phoneNumber;
    }

        public Boolean getDefaultAddress() {
                return isDefaultAddress;
        }

        public void setDefaultAddress(Boolean defaultAddress) {
                isDefaultAddress = defaultAddress;
        }

        @Override
        public int hashCode() {
                final int prime = 31;
                int result = 1;
                result = prime * result + ((city == null) ? 0 : city.hashCode());
                result = prime * result + ((country == null) ? 0 : country.hashCode());
                result = prime * result + id;
                result = prime * result + ((landmark == null) ? 0 : landmark.hashCode());
                result = prime * result + ((line1 == null) ? 0 : line1.hashCode());
                result = prime * result + ((line2 == null) ? 0 : line2.hashCode());
                result = prime * result + ((name == null) ? 0 : name.hashCode());
                result = prime * result + ((phoneNumber == null) ? 0 : phoneNumber.hashCode());
                result = prime * result + ((pinCode == null) ? 0 : pinCode.hashCode());
                result = prime * result + ((state == null) ? 0 : state.hashCode());
                return result;
        }
        
        public String getLastName() {
                return lastName;
        }
        public void setLastName(String lastName) {
                this.lastName = lastName;
        }
        @Override
        public boolean equals(Object obj) {
                if (this == obj)
                        return true;
                if (obj == null)
                        return false;
                if (getClass() != obj.getClass())
                        return false;
                CustomAddress other = (CustomAddress) obj;
                if (city == null) {
                        if (other.city != null)
                                return false;
                } else if (!city.equals(other.city))
                        return false;
                if (country == null) {
                        if (other.country != null)
                                return false;
                } else if (!country.equals(other.country))
                        return false;
                if (id != other.id)
                        return false;
                if (landmark == null) {
                        if (other.landmark != null)
                                return false;
                } else if (!landmark.equals(other.landmark))
                        return false;
                if (line1 == null) {
                        if (other.line1 != null)
                                return false;
                } else if (!line1.equals(other.line1))
                        return false;
                if (line2 == null) {
                        if (other.line2 != null)
                                return false;
                } else if (!line2.equals(other.line2))
                        return false;
                if (name == null) {
                        if (other.name != null)
                                return false;
                } else if (!name.equals(other.name))
                        return false;
                if (phoneNumber == null) {
                        if (other.phoneNumber != null)
                                return false;
                } else if (!phoneNumber.equals(other.phoneNumber))
                        return false;
                if (pinCode == null) {
                        if (other.pinCode != null)
                                return false;
                } else if (!pinCode.equals(other.pinCode))
                        return false;
                if (state == null) {
                        if (other.state != null)
                                return false;
                } else if (!state.equals(other.state))
                        return false;
                return true;
        }


        public String getAddressString() {
                StringBuilder sb = new StringBuilder();

                if (line1 != null && !line1.isEmpty()) {
                        sb.append(line1).append(", ");
                }
                if (line2 != null && !line2.isEmpty()) {
                        sb.append(line2).append(", ");
                }
                if (landmark != null && !landmark.isEmpty()) {
                        sb.append("Landmark: ").append(landmark).append(", ");
                }
                if (city != null && !city.isEmpty()) {
                        sb.append(city).append(", ");
                }
                if (state != null && !state.isEmpty()) {
                        sb.append(state).append(", ");
                }
                if (pinCode != null && !pinCode.isEmpty()) {
                        sb.append("PIN-").append(pinCode).append(", ");
                }
                if (country != null && !country.isEmpty()) {
                        sb.append(country).append(", ");
                }
                if (phoneNumber != null && !phoneNumber.isEmpty()) {
                        sb.append("Ph: ").append(phoneNumber);
                }

                // remove trailing comma/space
                String result = sb.toString().trim();
                if (result.endsWith(",")) {
                        result = result.substring(0, result.length() - 1).trim();
                }
                return result;
        }

        @Override
        public String toString() {
                return "CustomAddress{" +
                                "id=" + id +
                                ", name='" + name + '\'' +
                                ", lastName='" + lastName + '\'' +
                                ", line1='" + line1 + '\'' +
                                ", line2='" + line2 + '\'' +
                                ", landmark='" + landmark + '\'' +
                                ", city='" + city + '\'' +
                                ", state='" + state + '\'' +
                                ", pinCode='" + pinCode + '\'' +
                                ", country='" + country + '\'' +
                                ", phoneNumber='" + phoneNumber + '\'' +
                                ", isDefaultAddress=" + isDefaultAddress +
                                '}';
        }
}