package cn.com.qmth.stmms.biz.exam.model;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.persistence.EmbeddedId;
import javax.persistence.Entity;
import javax.persistence.Table;

@Entity
@Table(name = "eb_objective_question")
public class ObjectiveQuestion implements Serializable {

    private static final long serialVersionUID = 3741809791151768467L;

    @EmbeddedId
    private ObjectiveQuestionPK pk;

    private String title;

    private String answer;

    public ObjectiveQuestion() {
        this.pk = new ObjectiveQuestionPK();
    }

    public Integer getBlockId() {
        return pk.getBlockId();
    }

    public void setBlockId(Integer blockId) {
        this.pk.setBlockId(blockId);
    }

    public Integer getNumber() {
        return pk.getNumber();
    }

    public void setNumber(Integer number) {
        this.pk.setNumber(number);
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getAnswer() {
        return answer;
    }

    public void setAnswer(String answer) {
        this.answer = answer;
    }

}

@Embeddable
class ObjectiveQuestionPK implements Serializable {

    private static final long serialVersionUID = 7792928307824264023L;

    @Column(name = "block_id")
    private Integer blockId;

    private Integer number;

    public ObjectiveQuestionPK() {

    }

    @Override
    public int hashCode() {
        final int PRIME = 31;
        int result = 1;
        result = PRIME * result + ((blockId == null) ? 0 : blockId.hashCode());
        result = PRIME * result + ((number == null) ? 0 : number.hashCode());
        return result;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj)
            return true;
        if (obj == null)
            return false;
        if (getClass() != obj.getClass())
            return false;
        final ObjectiveQuestionPK other = (ObjectiveQuestionPK) obj;
        if (blockId == null) {
            if (other.blockId != null)
                return false;
        } else if (!blockId.equals(other.blockId))
            return false;
        if (number == null) {
            if (other.number != null)
                return false;
        } else if (!number.equals(other.number))
            return false;
        return true;
    }

    public Integer getBlockId() {
        return blockId;
    }

    public void setBlockId(Integer blockId) {
        this.blockId = blockId;
    }

    public Integer getNumber() {
        return number;
    }

    public void setNumber(Integer number) {
        this.number = number;
    }
}
