package api.unicharge.component;
 
import static api.util.ComponentConstants.BOOLEAN_NULL;
import static api.util.ComponentConstants.BOOLEAN_NULL_CODE;
import static api.util.ComponentConstants.INTEGER_NULL;
import static api.util.ComponentConstants.INTEGER_NULL_CODE;
import static api.util.ComponentConstants.LONG_NULL;
import static api.util.ComponentConstants.LONG_NULL_CODE;
import static api.util.ComponentConstants.STRING_NULL;
import static api.util.ComponentConstants.STRING_NULL_CODE;
import static org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion.NON_NULL;
 
import api.UnoComponent;
import api.unicharge.component_manual.PostRule;
import api.util.BooleanFormat;
import api.util.IntegerFormat;
import api.util.LongFormat;
import api.util.StringFormat;
import iapp.services.ServerObject;
import iapp.util.audit.AuditHelper;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.FormParam;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlSeeAlso;
import javax.xml.bind.annotation.XmlType;
import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
import org.codehaus.jackson.annotate.JsonPropertyOrder;
import org.codehaus.jackson.map.annotate.JsonDeserialize;
import org.codehaus.jackson.map.annotate.JsonSerialize;
 
/**
 * @author CodeGen [Liza Zhydok]
 * @company UnitedThinkers
 * @since 2014/07/17
 */
 
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"id", "isActive", "avsCodeList", "cscCodeList", "operatorType", "actionType", "amount", "userMessage", "priority"})
@JsonPropertyOrder({"id", "isActive", "avsCodeList", "cscCodeList", "operatorType", "actionType", "amount", "userMessage", "priority"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(PostRule.class)
public abstract class AbstractPostRule extends UnoComponent<unicharge.model.PostRule> {
 
    @FormParam("id")
    @LongFormat
    @DefaultValue(LONG_NULL_CODE)
    protected Long id;
 
    @FormParam("isActive")
    @BooleanFormat
    @DefaultValue(BOOLEAN_NULL_CODE)
    protected Boolean isActive;
 
    @FormParam("avsCodeList")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String avsCodeList;
 
    @FormParam("cscCodeList")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String cscCodeList;
 
    @FormParam("operatorType")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String operatorType;
 
    @FormParam("actionType")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String actionType;
 
    @FormParam("amount")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer amount;
 
    @FormParam("userMessage")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String userMessage;
 
    @FormParam("priority")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer priority;
 
 
    public AbstractPostRule(){
        super();
        applyDefaults();
    }
 
    public AbstractPostRule(unicharge.model.PostRule object){
        super(object);
    }
 
 
    private void applyDefaults() {
        if (!isProxyObject()) {
            id = LONG_NULL;
            isActive = BOOLEAN_NULL;
            avsCodeList = STRING_NULL;
            cscCodeList = STRING_NULL;
            operatorType = STRING_NULL;
            actionType = STRING_NULL;
            amount = INTEGER_NULL;
            userMessage = STRING_NULL;
            priority = INTEGER_NULL;
        }
    }
 
    @Override
    public void from() {
        fromInternal();
        super.from();
    }
 
    protected abstract void fromInternal();
    @Override
    public abstract void to();
    @Override
    public abstract void initializeNew();
 
    @Override
    public String toString(){
        StringBuilder sb = new StringBuilder();
        sb.append("post-rule: {");
        sb.append("id: ");
        sb.append(id);
        sb.append(',').append(' ');
        sb.append("isActive: ");
        sb.append(isActive);
        sb.append(',').append(' ');
        sb.append("avsCodeList: ");
        sb.append(avsCodeList);
        sb.append(',').append(' ');
        sb.append("cscCodeList: ");
        sb.append(cscCodeList);
        sb.append(',').append(' ');
        sb.append("operatorType: ");
        sb.append(operatorType);
        sb.append(',').append(' ');
        sb.append("actionType: ");
        sb.append(actionType);
        sb.append(',').append(' ');
        sb.append("amount: ");
        sb.append(amount);
        sb.append(',').append(' ');
        sb.append("userMessage: ");
        sb.append(userMessage);
        sb.append(',').append(' ');
        sb.append("priority: ");
        sb.append(priority);
        sb.append('}');
        return sb.toString();
    }
 
 
    @XmlAttribute(name="id")
    @XmlJavaTypeAdapter(value=api.util.LongAdapter.class, type=Long.class)
    @FormParam("id")
    @LongFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Long getId(){
        return id;
    }
 
    public void setId(Long value){
        this.id = value;
    }
 
    @XmlAttribute(name="isActive")
    @FormParam("isActive")
    @BooleanFormat
    public Boolean getIsActive(){
        return isActive;
    }
 
    public void setIsActive(Boolean value){
        this.isActive = value;
    }
 
    @XmlAttribute(name="avsCodeList")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("avsCodeList")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getAvsCodeList(){
        return avsCodeList;
    }
 
    public void setAvsCodeList(String value){
        this.avsCodeList = value;
    }
 
    @XmlAttribute(name="cscCodeList")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("cscCodeList")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getCscCodeList(){
        return cscCodeList;
    }
 
    public void setCscCodeList(String value){
        this.cscCodeList = value;
    }
 
    @XmlAttribute(name="operatorType")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("operatorType")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getOperatorType(){
        return operatorType;
    }
 
    public void setOperatorType(String value){
        this.operatorType = value;
    }
 
    @XmlAttribute(name="actionType")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("actionType")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getActionType(){
        return actionType;
    }
 
    public void setActionType(String value){
        this.actionType = value;
    }
 
    @XmlAttribute(name="amount")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("amount")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Integer getAmount(){
        return amount;
    }
 
    public void setAmount(Integer value){
        this.amount = value;
    }
 
    @XmlAttribute(name="userMessage")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("userMessage")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getUserMessage(){
        return userMessage;
    }
 
    public void setUserMessage(String value){
        this.userMessage = value;
    }
 
    @XmlAttribute(name="priority")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("priority")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Integer getPriority(){
        return priority;
    }
 
    public void setPriority(Integer value){
        this.priority = value;
    }
 
 
    public void audit(AuditHelper helper, ServerObject object) {
        unicharge.model.PostRule s_object = (unicharge.model.PostRule) object;
        helper.audit("id", id, s_object.getId());
        helper.audit("isActive", isActive, s_object.getIsActive());
        helper.audit("avsCodeList", avsCodeList, s_object.getAvsCodeList());
        helper.audit("cscCodeList", cscCodeList, s_object.getCscCodeList());
        helper.audit("operatorType", operatorType, s_object.getRuleOperatorCl() == null ? null : s_object.getRuleOperatorCl().getValue());
        helper.audit("actionType", actionType, s_object.getRuleActionCl() == null ? null : s_object.getRuleActionCl().getValue());
        helper.audit("amount", amount, s_object.getAmount());
        helper.audit("userMessage", userMessage, s_object.getUserMessage());
 
    }
 
    public static String objectTypeCode(){
        return "post-rule";
    }
 
}