All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.evasion.entity.geolocation.Geoname Maven / Gradle / Ivy

The newest version!
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.evasion.entity.geolocation;

import java.io.Serializable;
import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.Temporal;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;

/**
 *
 * @author sglon
 */
@Embeddable
public class Geoname implements Serializable {

    /**
     * *
     * serialVersionUID.
     */
    private static final long serialVersionUID = 1L;
    @Column(unique = true, nullable = true)
    private int geonameId;
    /**
     * Date de derniere mise à jour.
     */
    @Temporal(javax.persistence.TemporalType.DATE)
    private Calendar modDateInternal;

    /**
     * Constructeur par défaut pour la persistence.
     */
    public Geoname() {
    }

    /**
     * Constructeur général.
     *
     * @param geonameId identifiant d'import depuis la base Geonames.org
     * @param modDate Date de dernière modification de la base Geonames.org.
     */
    public Geoname(int geonameId, Date modDate) {
        this.geonameId = geonameId;
        Calendar cal = new GregorianCalendar();
        cal.setTime(modDate);
        this.modDateInternal = cal;
    }

    public int getGeonameId() {
        return this.geonameId;
    }

    public void setGeonameId(int geonameId) {
        this.geonameId = geonameId;
    }

    public Date getModDate() {
        if (getModDateInternal() == null) {
            return null;
        } else {
            return getModDateInternal().getTime();
        }

    }

    public void setModDate(Date modDate) {
        Calendar cal = new GregorianCalendar();
        cal.setTime(modDate);
        this.setModDateInternal(cal);
    }

    protected Calendar getModDateInternal() {
        return modDateInternal;
    }

    protected void setModDateInternal(Calendar modDateInternal) {
        this.modDateInternal = modDateInternal;
    }

    /**
     * {@inheritDoc }
     */
    @Override
    public boolean equals(final Object obj) {
        if (obj == null) {
            return false;
        }
        if (this == obj) {
            return true;
        }
        if (!(obj instanceof Geoname)) {
            return false;
        }
        Geoname rhs = (Geoname) obj;

        return new EqualsBuilder().append(this.geonameId, rhs.geonameId).
                isEquals();
    }

    /**
     * @{@inheritDoc }
     */
    @Override
    public int hashCode() {
        return new HashCodeBuilder(17, 37).append(this.geonameId).toHashCode();
    }

    /**
     * @{@inheritDoc }
     */
    @Override
    public String toString() {
        return new ToStringBuilder(this).append(this.getClass().getName()).
                append("[").
                append("geonameId=", geonameId).
                append("lastModDate", modDateInternal).
                append("]").
                toString();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy