view src/main/java/de/mpiwg/gazetteer/bo/Sequence.java @ 0:7682c04c63a8

First commit of the source code!
author "jurzua <jurzua@mpiwg-berlin.mpg.de>"
date Tue, 10 Mar 2015 14:50:41 +0100
parents
children
line wrap: on
line source

package de.mpiwg.gazetteer.bo;

import java.io.Serializable;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;

/**
 *
 * @author jurzua
 */
@Entity
@Table(name="row_sequence")
public class Sequence implements Serializable {
	
	private static final long serialVersionUID = 120128920808559599L;

	public Sequence(){}
    
    public Sequence(String name, Long value){
        this.lastValue = value;
        this.name = name;
    }

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    @Column(name="name")
    private String name;

    @Column(name="last_value")
    private Long lastValue;

    public Long generateId(){
        return this.lastValue++;
    }

    public Long getLastValue() {
        return lastValue;
    }

    public void setLastValue(Long lastValue) {
        this.lastValue = lastValue;
    }

    public String getName() {
        return name;
    }

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



    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Sequence)) {
            return false;
        }
        Sequence other = (Sequence) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.mpi.openmind.ontology.joins.Sequence[id=" + id + "]";
    }

}