![JAR search and dependency download from the Maven repository](/logo.png)
com.evasion.entity.geolocation.Continent Maven / Gradle / Ivy
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package com.evasion.entity.geolocation;
import java.util.List;
import javax.persistence.*;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
/**
*
* @author sglon
*/
@Entity(name=Continent.ENTITY_NAME)
@Table(name = Continent.ENTITY_NAME)
@AttributeOverrides({
@AttributeOverride(name = "latitude", column =
@Column(nullable = true)),
@AttributeOverride(name = "longitude", column =
@Column(nullable = true))
})
public class Continent extends Location {
/**
* *
* serialVersionUID.
*/
private static final long serialVersionUID = 1L;
public static final String ENTITY_NAME = "GEO_CONTINENT";
/**
* Taille max d'un code continent.
*/
public static final int CODE_MAX_LENGTH = 2;
/**
* Code d'un continent.
*/
@Column(unique = true, nullable = false, length = CODE_MAX_LENGTH)
private String code;
// @TODO ajouter les accesseurs et modificateurs
@OneToMany(mappedBy="continent")
private List countries;
@Embedded
private Geoname geoname;
/**
* Constructeur pour la persistance.
*/
public Continent() {
}
/**
* Constructeur par defaut.
* @param code Code normalise sur 2 caractères.
* @param name Nom du continent.
*/
protected Continent(String code, String name) {
super(name);
this.code = code;
}
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
public Geoname getGeoname() {
return geoname;
}
public void setGeoname(Geoname geoname) {
this.geoname = geoname;
}
/**
* {@inheritDoc }
*/
@Override
public boolean equals(final Object obj) {
if (obj == null) {
return false;
}
if (this == obj) {
return true;
}
if (!(obj instanceof Continent)) {
return false;
}
Continent rhs = (Continent) obj;
return new EqualsBuilder().append(this.code, rhs.code).isEquals();
}
/**
* Calcul du hashcode sur la clé naturelle.
* @return valeur du hashCode.
*/
@Override
public int hashCode() {
return new HashCodeBuilder().append(this.code).toHashCode();
}
@Override
public String toString() {
return new ToStringBuilder(this).append("id", this.getId()).
append("code", this.code).append("name", this.getName()).toString();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy