package api.unicore.component;
 
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.unicore.component_manual.MerchantDepositInfo;
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 [Anton Shershnov]
 * @company UnitedThinkers
 * @since 2012/09/02
 */
 
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"holderName", "routingNumber", "accountNumber", "tokenCode", "bankName", "bankPhone", "accountType"})
@JsonPropertyOrder({"holderName", "routingNumber", "accountNumber", "tokenCode", "bankName", "bankPhone", "accountType"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(MerchantDepositInfo.class)
public abstract class AbstractMerchantDepositInfo extends UnoComponent<unicore.model.MerchantAccountGroup> {
 
    @FormParam("holderName")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String holderName;
 
    @FormParam("routingNumber")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String routingNumber;
 
    @FormParam("accountNumber")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String accountNumber;
 
    @FormParam("tokenCode")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String tokenCode;
 
    @FormParam("bankName")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String bankName;
 
    @FormParam("bankPhone")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String bankPhone;
 
    @FormParam("accountType")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String accountType;
 
 
    public AbstractMerchantDepositInfo(){
        super();
        applyDefaults();
    }
 
    public AbstractMerchantDepositInfo(unicore.model.MerchantAccountGroup object){
        super(object);
    }
 
 
    private void applyDefaults() {
        if (!isProxyObject()) {
            holderName = STRING_NULL;
            routingNumber = STRING_NULL;
            accountNumber = STRING_NULL;
            tokenCode = STRING_NULL;
            bankName = STRING_NULL;
            bankPhone = STRING_NULL;
            accountType = STRING_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("deposit-info: {");
        sb.append("holderName: ");
        sb.append(holderName);
        sb.append(',').append(' ');
        sb.append("routingNumber: ");
        sb.append(routingNumber);
        sb.append(',').append(' ');
        sb.append("accountNumber: ");
        sb.append(accountNumber);
        sb.append(',').append(' ');
        sb.append("tokenCode: ");
        sb.append(tokenCode);
        sb.append(',').append(' ');
        sb.append("bankName: ");
        sb.append(bankName);
        sb.append(',').append(' ');
        sb.append("bankPhone: ");
        sb.append(bankPhone);
        sb.append(',').append(' ');
        sb.append("accountType: ");
        sb.append(accountType);
        sb.append('}');
        return sb.toString();
    }
 
 
    @XmlAttribute(name="holderName")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("holderName")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getHolderName(){
        return holderName;
    }
 
    public void setHolderName(String value){
        this.holderName = value;
    }
 
    @XmlAttribute(name="routingNumber")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("routingNumber")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getRoutingNumber(){
        return routingNumber;
    }
 
    public void setRoutingNumber(String value){
        this.routingNumber = value;
    }
 
    @XmlAttribute(name="accountNumber")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("accountNumber")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getAccountNumber(){
        return accountNumber;
    }
 
    public void setAccountNumber(String value){
        this.accountNumber = value;
    }
 
    @XmlAttribute(name="tokenCode")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("tokenCode")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getTokenCode(){
        return tokenCode;
    }
 
    public void setTokenCode(String value){
        this.tokenCode = value;
    }
 
    @XmlAttribute(name="bankName")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("bankName")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getBankName(){
        return bankName;
    }
 
    public void setBankName(String value){
        this.bankName = value;
    }
 
    @XmlAttribute(name="bankPhone")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("bankPhone")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getBankPhone(){
        return bankPhone;
    }
 
    public void setBankPhone(String value){
        this.bankPhone = value;
    }
 
    @XmlAttribute(name="accountType")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("accountType")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getAccountType(){
        return accountType;
    }
 
    public void setAccountType(String value){
        this.accountType = value;
    }
 
 
    public void audit(AuditHelper helper, ServerObject object) {
        unicore.model.MerchantAccountGroup s_object = (unicore.model.MerchantAccountGroup) object;
        helper.audit("holderName", holderName, s_object.getBankAccountHolderName());
        helper.audit("routingNumber", routingNumber, s_object.getBankRoutingNumberMasked());
        helper.audit("accountNumber", accountNumber, s_object.getBankAccountNumberMasked());
        helper.audit("tokenCode", tokenCode, s_object.getTokenCode());
        helper.audit("bankName", bankName, s_object.getBankName());
        helper.audit("bankPhone", bankPhone, s_object.getBankPhone());
        helper.audit("accountType", accountType, s_object.getBankAccountTypeCl());
 
    }
 
    public static String objectTypeCode(){
        return "deposit-info";
    }
 
}