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

com.evasion.entity.geolocation.Location 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 com.evasion.EntityJPA;
import java.io.Serializable;
import javax.persistence.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.compass.annotations.Searchable;
import org.compass.annotations.SearchableId;
import org.compass.annotations.SearchableProperty;

/**
 *
 * @author sglon
 */
@Entity(name = Location.ENTITY_NAME)
@Table(name = Location.ENTITY_NAME)
@Searchable(alias = "location")
@Inheritance(strategy = InheritanceType.TABLE_PER_CLASS)
@NamedQuery(name = Location.QUERY_FIND_LIKE_NAME, query = "select l from " + Location.ENTITY_NAME + " l where l." + Location.ATTR_NAME + " like ?1")
public class Location extends EntityJPA {

    /**
     * *
     * serialVersionUID.
     */
    private static final long serialVersionUID = 1L;
    public static final String QUERY_FIND_LIKE_NAME = "findLikeName";
    public static final String ENTITY_NAME = "GEO_LOCATION";
    /**
     * Id technique.
     */
    @Id
    @GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "GEOLOC_SEQ")
    @SearchableId
    private Long id;
    /**
     * Taille max d'un nom d'une localisation.
     */
    public static final int NAME_MAX_LENGTH = 200;
    public static final String ATTR_NAME = "name";
    /**
     * Non du continent.
     */
    @SearchableProperty(name = ATTR_NAME)
    @Column(unique = false, nullable = false, length = NAME_MAX_LENGTH)
    private String name;
    @Column(nullable=false)
    private Double latitude;
    @Column(nullable=false)
    private Double longitude;
    @Column(nullable=true)
    private Integer altitude;

    public Location() {
    }

    public Location(String name) {
        this.name = name;
    }

    public Location(Location location) {
        if (location != null) {
            this.latitude = location.latitude;
            this.longitude = location.longitude;
            this.name = location.name;
            this.altitude = location.altitude;
        }
    }

    public Location(String name, Double latitude, Double longitude) {
        this.name = name;
        this.latitude = latitude;
        this.longitude = longitude;
    }

    @Override
    public Long getId() {
        return this.id;
    }

    /**
     * Setter de l'ID technique.
     *
     * @param id ID technique.
     */
    public void setId(Long id) {
        this.id = id;
    }

    public Integer getAltitude() {
        return altitude;
    }

    public void setAltitude(Integer altitude) {
        this.altitude = altitude;
    }

    public Double getLongitude() {
        return longitude;
    }

    public void setLongitude(Double longitude) {
        this.longitude = longitude;
    }

    public Double getLatitude() {
        return latitude;
    }

    public void setLatitude(Double latitude) {
        this.latitude = latitude;
    }

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

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

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

        return new EqualsBuilder().append(this.name, rhs.name).append(this.latitude, rhs.latitude).append(this.longitude, rhs.longitude).
                isEquals();
    }

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

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy