/*
* Copyright (C) 2012 maartenl
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package mmud.database.entities.game;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
/**
*
* @author maartenl
*/
@Embeddable
public class AnswerPK implements Serializable
{
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 20)
@Column(name = "name")
private String name;
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 80)
@Column(name = "question")
private String question;
public AnswerPK()
{
}
public AnswerPK(String name, String question)
{
this.name = name;
this.question = question;
}
public String getName()
{
return name;
}
public void setName(String name)
{
this.name = name;
}
public String getQuestion()
{
return question;
}
public void setQuestion(String question)
{
this.question = question;
}
@Override
public int hashCode()
{
int hash = 0;
hash += (name != null ? name.hashCode() : 0);
hash += (question != null ? question.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 AnswerPK))
{
return false;
}
AnswerPK other = (AnswerPK) object;
if ((this.name == null && other.name != null) || (this.name != null && !this.name.equals(other.name)))
{
return false;
}
if ((this.question == null && other.question != null) || (this.question != null && !this.question.equals(other.question)))
{
return false;
}
return true;
}
@Override
public String toString()
{
return "mmud.database.entities.game.AnswerPK[ name=" + name + ", question=" + question + " ]";
}
}