package com.k_int.discover.lookup.datamodel;

/**
 * A simple DTO type class to manage location match information to be returned to the called
 * @author rpb rich@k-int.com
 * @version 1.0 18.01.11
 */
public class LocationLookupResultDTO {

    public String name;
    public Double lat;
    public Double lng;

    public LocationLookupResultDTO() {
        super();
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getName() {
        return this.name;
    }

    public void setLat(Double lat) {
        this.lat = lat;
    }

    public Double getLat() {
        return this.lat;
    }

    public void setLng(Double lng) {
        this.lng = lng;
    }

    public Double getLng() {
        return this.lng;
    }

    @Override
    public boolean equals(Object obj) {
        if (obj == null) {
            return false;
        }
        if (getClass() != obj.getClass()) {
            return false;
        }
        final LocationLookupResultDTO other = (LocationLookupResultDTO) obj;
        if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
            return false;
        }
        if (this.lat != other.lat && (this.lat == null || !this.lat.equals(other.lat))) {
            return false;
        }
        if (this.lng != other.lng && (this.lng == null || !this.lng.equals(other.lng))) {
            return false;
        }
        return true;
    }

    @Override
    public int hashCode() {
        int hash = 3;
        hash = 13 * hash + (this.name != null ? this.name.hashCode() : 0);
        hash = 13 * hash + (this.lat != null ? this.lat.hashCode() : 0);
        hash = 13 * hash + (this.lng != null ? this.lng.hashCode() : 0);
        return hash;
    }


    public String toXML() {
        StringBuilder response = new StringBuilder();
        response.append("<location>");
        response.append("<name>").append(this.name).append("</name>");
        response.append("<lat>").append(this.lat).append("</lat>");
        response.append("<long>").append(this.lng).append("</long>");
        response.append("</location>");

        return response.toString();
    }

    public String toJSON() {
        StringBuilder response = new StringBuilder();
        response.append("{\"name\":\"").append(this.name).append("\"");
        response.append(",\"lat\":").append(this.lat);
        response.append(",\"long\":").append(this.lng).append("}");
        return response.toString();
    }

}
