/**
 * 
 */
package com.lisasoft.routedirections.ard.beans;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

import org.hibernate.annotations.Type;
import org.postgis.Geometry;

@Entity
final public class Location implements Serializable 
{
	/**
	 * Hibernate primary key
	 */
	private long id;

	/**
	 * The locations name
	 */
	private String name;
	
		
	/**
	 * This is the postgis Geometry field
	 * @see org.postgis.Point
	 */
	private Geometry geom;

	/**
	 * Serializable ID
	 */
	private static final long serialVersionUID = 1L;
	
	/**
	 * Default Constructor for Addresses.
	 */
	public Location() {		
		super();
	}

	/**
	 * Create a new Location
	 * @param name self explainitory
	 * @param geometry this is a 2 Dimensional Point
	 * @see org.postgis.Point
	 */
	public Location(String name, Geometry geom) {
	//public Location(String name, Geometry theGeom) {
		this();
		this.name = name;
		this.geom = geom;
	}

	/**
	 * @return Returns the id.
	 */
	@Id
	@GeneratedValue
	public long getId() {
		return id;
	}

	/**
	 * @param locationId
	 *            The id to set.
	 */
	public void setId(final long locationId) {
		this.id = locationId;
	}


	public String getName() {
		return name;
	}

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

	@Type(type = "org.postgis.hibernate.GeometryType")
	@Column(name="geom", columnDefinition="Geometry")
	public Geometry getGeom() {
		return geom;
	}
	public void setGeom(Geometry geom) {
		this.geom = geom;
	}

	
	/**
	 * Overwritten toString method
	 * 
	 * @return String
	 */
	public String toString() 
	{
		final StringBuffer retString = new StringBuffer(35);
		retString.append("ID: ");
		retString.append(id);
		retString.append(", Name: ");
		retString.append(name);
		retString.append(", Geometry: ");
		retString.append(""+geom);
		return retString.toString();
	}

}