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;
import javax.persistence.Transient;

@Entity
@Table(name = "eb_mark_level")
public class MarkLevel implements Serializable {

    private static final long serialVersionUID = 6710328491557700440L;

    @EmbeddedId
    private MarkLevelPK pk;

    private String name;

    private Double min;

    private Double max;

    @Transient
    private double[] scoreList;

    public MarkLevel() {
        this.pk = new MarkLevelPK();
    }

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

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

    public Integer getStepNumber() {
        return this.pk.getStepNumber();
    }

    public void setStepNumber(Integer stepNumber) {
        this.pk.setStepNumber(stepNumber);
    }

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

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

    public String getName() {
        return name;
    }

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

    public Double getMin() {
        return min;
    }

    public void setMin(Double min) {
        this.min = min;
    }

    public Double getMax() {
        return max;
    }

    public void setMax(Double max) {
        this.max = max;
    }

    public double[] getScoreList() {
        return scoreList;
    }

    public void setScoreList(double[] scoreList) {
        this.scoreList = scoreList;
    }

}

@Embeddable
class MarkLevelPK implements Serializable {

    private static final long serialVersionUID = -5296472857826912303L;

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

    @Column(name = "step_number")
    private Integer stepNumber;

    private Integer number;

    public MarkLevelPK() {

    }

    @Override
    public int hashCode() {
        final int PRIME = 31;
        int result = 1;
        result = PRIME * result + ((blockId == null) ? 0 : blockId.hashCode());
        result = PRIME * result + ((stepNumber == null) ? 0 : stepNumber.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 MarkLevelPK other = (MarkLevelPK) obj;
        if (blockId == null) {
            if (other.blockId != null)
                return false;
        } else if (!blockId.equals(other.blockId)) {
            return false;
        }
        if (stepNumber == null) {
            if (other.stepNumber != null)
                return false;
        } else if (!stepNumber.equals(other.stepNumber)) {
            return false;
        }
        if (number == null) {
            if (other.number != null)
                return false;
        } else if (!number.equals(other.number)) {
            return false;
        }
        return true;
    }

    public Integer getNumber() {
        return number;
    }

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

    public Integer getBlockId() {
        return blockId;
    }

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

    public Integer getStepNumber() {
        return stepNumber;
    }

    public void setStepNumber(Integer stepNumber) {
        this.stepNumber = stepNumber;
    }

}
