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.PreRule;
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 2015/02/10
 */
 
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"id", "isActive", "billingCountryCodeList", "billingStateCodeList", "issuingCountryCodeList", "cardTypeList", "actionType", "operatorType", "amount", "userMessage", "priority"})
@JsonPropertyOrder({"id", "isActive", "billingCountryCodeList", "billingStateCodeList", "issuingCountryCodeList", "cardTypeList", "actionType", "operatorType", "amount", "userMessage", "priority"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(PreRule.class)
public abstract class AbstractPreRule extends UnoComponent<unicharge.model.PreRule> {
 
    @FormParam("id")
    @LongFormat
    @DefaultValue(LONG_NULL_CODE)
    protected Long id;
 
    @FormParam("isActive")
    @BooleanFormat
    @DefaultValue(BOOLEAN_NULL_CODE)
    protected Boolean isActive;
 
    @FormParam("billingCountryCodeList")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String billingCountryCodeList;
 
    @FormParam("billingStateCodeList")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String billingStateCodeList;
 
    @FormParam("issuingCountryCodeList")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String issuingCountryCodeList;
 
    @FormParam("cardTypeList")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String cardTypeList;
 
    @FormParam("actionType")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String actionType;
 
    @FormParam("operatorType")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String operatorType;
 
    @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 AbstractPreRule(){
        super();
        applyDefaults();
    }
 
    public AbstractPreRule(unicharge.model.PreRule object){
        super(object);
    }
 
 
    private void applyDefaults() {
        if (!isProxyObject()) {
            id = LONG_NULL;
            isActive = BOOLEAN_NULL;
            billingCountryCodeList = STRING_NULL;
            billingStateCodeList = STRING_NULL;
            issuingCountryCodeList = STRING_NULL;
            cardTypeList = STRING_NULL;
            actionType = STRING_NULL;
            operatorType = 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("pre-rule: {");
        sb.append("id: ");
        sb.append(id);
        sb.append(',').append(' ');
        sb.append("isActive: ");
        sb.append(isActive);
        sb.append(',').append(' ');
        sb.append("billingCountryCodeList: ");
        sb.append(billingCountryCodeList);
        sb.append(',').append(' ');
        sb.append("billingStateCodeList: ");
        sb.append(billingStateCodeList);
        sb.append(',').append(' ');
        sb.append("issuingCountryCodeList: ");
        sb.append(issuingCountryCodeList);
        sb.append(',').append(' ');
        sb.append("cardTypeList: ");
        sb.append(cardTypeList);
        sb.append(',').append(' ');
        sb.append("actionType: ");
        sb.append(actionType);
        sb.append(',').append(' ');
        sb.append("operatorType: ");
        sb.append(operatorType);
        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="billingCountryCodeList")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("billingCountryCodeList")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getBillingCountryCodeList(){
        return billingCountryCodeList;
    }
 
    public void setBillingCountryCodeList(String value){
        this.billingCountryCodeList = value;
    }
 
    @XmlAttribute(name="billingStateCodeList")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("billingStateCodeList")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getBillingStateCodeList(){
        return billingStateCodeList;
    }
 
    public void setBillingStateCodeList(String value){
        this.billingStateCodeList = value;
    }
 
    @XmlAttribute(name="issuingCountryCodeList")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("issuingCountryCodeList")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getIssuingCountryCodeList(){
        return issuingCountryCodeList;
    }
 
    public void setIssuingCountryCodeList(String value){
        this.issuingCountryCodeList = value;
    }
 
    @XmlAttribute(name="cardTypeList")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("cardTypeList")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getCardTypeList(){
        return cardTypeList;
    }
 
    public void setCardTypeList(String value){
        this.cardTypeList = 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="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="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.PreRule s_object = (unicharge.model.PreRule) object;
        helper.audit("id", id, s_object.getId());
        helper.audit("isActive", isActive, s_object.getIsActive());
        helper.audit("billingCountryCodeList", billingCountryCodeList, s_object.getBillingCountryCodeList());
        helper.audit("billingStateCodeList", billingStateCodeList, s_object.getBillingStateCodeList());
        helper.audit("issuingCountryCodeList", issuingCountryCodeList, s_object.getIssuingCountryCodeList());
        helper.audit("cardTypeList", cardTypeList, s_object.getCardTypeList());
        helper.audit("actionType", actionType, s_object.getRuleActionCl() == null ? null : s_object.getRuleActionCl().getValue());
        helper.audit("operatorType", operatorType, s_object.getRuleOperatorCl() == null ? null : s_object.getRuleOperatorCl().getValue());
        helper.audit("amount", amount, s_object.getAmount());
        helper.audit("userMessage", userMessage, s_object.getUserMessage());
 
    }
 
    public static String objectTypeCode(){
        return "pre-rule";
    }
 
}