ProductStateMetaData.java

package com.tradecloud.domain.configuration;

import com.tradecloud.domain.model.ordermanagement.ProductState;

import javax.persistence.*;
import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import java.io.Serializable;

/**
 * Meta-data of product state.
 */
@Entity
@Table(name = "productstatemetadata")
@Access(AccessType.FIELD)
@XmlAccessorType(XmlAccessType.FIELD)
@XmlRootElement(name = "ProductStateMetaData")
@NamedQueries({
        @NamedQuery(name = "productStateMetaData.inUse", query = "from ProductStateMetaData o where o.state = :state and o.type= :type")})
public class ProductStateMetaData extends StateMetaData<ProductState> implements Serializable, Comparable<ProductStateMetaData> {

    private static final long serialVersionUID = 1L;

    @Enumerated(value = EnumType.STRING)
    @XmlAttribute
    @NotNull
    private ProductState state;

    public static enum Type {
        FULL, ELC
    }

    @Enumerated(EnumType.STRING)
    private ProductStateMetaData.Type type = ProductStateMetaData.Type.FULL;

    public ProductStateMetaData() {

    }

    public ProductStateMetaData(ProductState state, boolean inUse) {
        super(inUse);
        this.state = state;
    }

    public Type getType() {
        return type;
    }

    public void setType(Type type) {
        this.type = type;
    }

    @Override
    public ProductState getState() {
        return state;
    }

    @Override
    public void setState(ProductState state) {
        this.state = state;
    }

    @Override
    public int compareTo(ProductStateMetaData o) {
        return state.compareTo(o.getState());
    }
}