package api.unibill.component;
 
import static api.util.ComponentConstants.DATE_NULL;
import static api.util.ComponentConstants.DATE_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.unicore.component_manual.ProcessingInfo;
import api.unicore.component_manual.Transaction;
import api.util.DateFormat;
import api.util.IntegerFormat;
import api.util.LongFormat;
import api.util.StringFormat;
import java.util.Date;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
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.XmlElement;
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;
import unipay.fields_manual.Fields;
import unipay.validator.CustomValidator;
import unipay.validator.EnumValidator;
 
/**
 * @author CodeGen [Kirill Zhukov]
 * @company UnitedThinkers
 * @since 2018/07/23
 */
 
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"id", "code", "accountId", "customerId", "createDate", "dueDate", "type", "accountType", "creatorCode", "amount", "balance", "accountNumber", "note", "adjustmentId", "subscriptionId", "processingInfo", "feeAmount"})
@JsonPropertyOrder({"id", "code", "accountId", "customerId", "createDate", "dueDate", "type", "accountType", "creatorCode", "amount", "balance", "accountNumber", "note", "adjustmentId", "subscriptionId", "processingInfo", "feeAmount"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(Transaction.class)
@CustomValidator
public abstract class AbstractTransaction extends UnoComponent<unibill.model.AccountTransaction> {
 
    @FormParam("id")
    @LongFormat
    @DefaultValue(LONG_NULL_CODE)
    protected Long id;
 
    @FormParam("code")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String code;
 
    @FormParam("accountId")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer accountId;
 
    @FormParam("customerId")
    @LongFormat
    @DefaultValue(LONG_NULL_CODE)
    protected Long customerId;
 
    @FormParam("createDate")
    @DateFormat
    @DefaultValue(DATE_NULL_CODE)
    protected Date createDate;
 
    @FormParam("dueDate")
    @DateFormat
    @DefaultValue(DATE_NULL_CODE)
    protected Date dueDate;
 
    @FormParam("type")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String type;
 
    @FormParam("accountType")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String accountType;
 
    @FormParam("creatorCode")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String creatorCode;
 
    @FormParam("amount")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer amount;
 
    @FormParam("balance")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer balance;
 
    @FormParam("accountNumber")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String accountNumber;
 
    @FormParam("note")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String note;
 
    @FormParam("adjustmentId")
    @LongFormat
    @DefaultValue(LONG_NULL_CODE)
    protected Long adjustmentId;
 
    @FormParam("subscriptionId")
    @LongFormat
    @DefaultValue(LONG_NULL_CODE)
    protected Long subscriptionId;
 
    protected ProcessingInfo processingInfo = new ProcessingInfo();
 
    @FormParam("feeAmount")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer feeAmount;
 
 
    public AbstractTransaction(){
        super();
        applyDefaults();
    }
 
    public AbstractTransaction(unibill.model.AccountTransaction object){
        super(object);
    }
 
 
    private void applyDefaults() {
        if (!isProxyObject()) {
            id = LONG_NULL;
            code = STRING_NULL;
            accountId = INTEGER_NULL;
            customerId = LONG_NULL;
            createDate = DATE_NULL;
            dueDate = DATE_NULL;
            type = STRING_NULL;
            accountType = STRING_NULL;
            creatorCode = STRING_NULL;
            amount = INTEGER_NULL;
            balance = INTEGER_NULL;
            accountNumber = STRING_NULL;
            note = STRING_NULL;
            adjustmentId = LONG_NULL;
            subscriptionId = LONG_NULL;
            processingInfo = null;
            feeAmount = 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("transaction: {");
        sb.append("id: ");
        sb.append(id);
        sb.append(',').append(' ');
        sb.append("code: ");
        sb.append(code);
        sb.append(',').append(' ');
        sb.append("accountId: ");
        sb.append(accountId);
        sb.append(',').append(' ');
        sb.append("customerId: ");
        sb.append(customerId);
        sb.append(',').append(' ');
        sb.append("createDate: ");
        sb.append(createDate);
        sb.append(',').append(' ');
        sb.append("dueDate: ");
        sb.append(dueDate);
        sb.append(',').append(' ');
        sb.append("type: ");
        sb.append(type);
        sb.append(',').append(' ');
        sb.append("accountType: ");
        sb.append(accountType);
        sb.append(',').append(' ');
        sb.append("creatorCode: ");
        sb.append(creatorCode);
        sb.append(',').append(' ');
        sb.append("amount: ");
        sb.append(amount);
        sb.append(',').append(' ');
        sb.append("balance: ");
        sb.append(balance);
        sb.append(',').append(' ');
        sb.append("accountNumber: ");
        sb.append(accountNumber);
        sb.append(',').append(' ');
        sb.append("note: ");
        sb.append(note);
        sb.append(',').append(' ');
        sb.append("adjustmentId: ");
        sb.append(adjustmentId);
        sb.append(',').append(' ');
        sb.append("subscriptionId: ");
        sb.append(subscriptionId);
        sb.append(',').append(' ');
        sb.append("processingInfo: ");
        sb.append(processingInfo);
        sb.append(',').append(' ');
        sb.append("feeAmount: ");
        sb.append(feeAmount);
        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="code")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("code")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 60)
    @Pattern(regexp = unipay.validator.PatternName.CODE)
    public String getCode(){
        return code;
    }
 
    public void setCode(String value){
        this.code = value;
    }
 
    @XmlAttribute(name="accountId")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("accountId")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Integer getAccountId(){
        return accountId;
    }
 
    public void setAccountId(Integer value){
        this.accountId = value;
    }
 
    @XmlAttribute(name="customerId")
    @XmlJavaTypeAdapter(value=api.util.LongAdapter.class, type=Long.class)
    @FormParam("customerId")
    @LongFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Long getCustomerId(){
        return customerId;
    }
 
    public void setCustomerId(Long value){
        this.customerId = value;
    }
 
    @XmlAttribute(name="createDate")
    @XmlJavaTypeAdapter(api.util.DateTimeAdapter.class)
    @FormParam("createDate")
    @DateFormat
    @JsonSerialize(using=api.util.DateTimeSerializer.class, include = NON_NULL)
    @JsonDeserialize(using=api.util.DateDeserializer.class)
    public Date getCreateDate(){
        return createDate;
    }
 
    public void setCreateDate(Date value){
        this.createDate = value;
    }
 
    @XmlAttribute(name="dueDate")
    @FormParam("dueDate")
    @DateFormat
    @JsonDeserialize(using=api.util.DateDeserializer.class)
    public Date getDueDate(){
        return dueDate;
    }
 
    public void setDueDate(Date value){
        this.dueDate = value;
    }
 
    @XmlAttribute(name="type")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("type")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @NotNull
    @Size(max = 2)
    @EnumValidator(unibill.model.AccountActivityClassifier.class)
    public String getType(){
        return type;
    }
 
    public void setType(String value){
        this.type = value;
    }
 
    @XmlAttribute(name="accountType")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("accountType")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 2)
    @EnumValidator(unibill.model.AssetTransactionClassifier.class)
    public String getAccountType(){
        return accountType;
    }
 
    public void setAccountType(String value){
        this.accountType = value;
    }
 
    @XmlAttribute(name="creatorCode")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("creatorCode")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 60)
    @Pattern(regexp = unipay.validator.PatternName.CODE)
    public String getCreatorCode(){
        return creatorCode;
    }
 
    public void setCreatorCode(String value){
        this.creatorCode = value;
    }
 
    @XmlAttribute(name="amount")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("amount")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    @NotNull
    @Min(1)
    public Integer getAmount(){
        return amount;
    }
 
    public void setAmount(Integer value){
        this.amount = value;
    }
 
    @XmlAttribute(name="balance")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("balance")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Integer getBalance(){
        return balance;
    }
 
    public void setBalance(Integer value){
        this.balance = value;
    }
 
    @XmlAttribute(name="accountNumber")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("accountNumber")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 50)
    public String getAccountNumber(){
        return accountNumber;
    }
 
    public void setAccountNumber(String value){
        this.accountNumber = value;
    }
 
    @XmlAttribute(name="note")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("note")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    @Size(max = 255)
    @Pattern(regexp = unipay.validator.PatternName.TEXT)
    public String getNote(){
        return note;
    }
 
    public void setNote(String value){
        this.note = value;
    }
 
    @XmlAttribute(name="adjustmentId")
    @XmlJavaTypeAdapter(value=api.util.LongAdapter.class, type=Long.class)
    @FormParam("adjustmentId")
    @LongFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Long getAdjustmentId(){
        return adjustmentId;
    }
 
    public void setAdjustmentId(Long value){
        this.adjustmentId = value;
    }
 
    @XmlAttribute(name="subscriptionId")
    @XmlJavaTypeAdapter(value=api.util.LongAdapter.class, type=Long.class)
    @FormParam("subscriptionId")
    @LongFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Long getSubscriptionId(){
        return subscriptionId;
    }
 
    public void setSubscriptionId(Long value){
        this.subscriptionId = value;
    }
 
    @XmlElement(name="processingInfo")
    public ProcessingInfo getProcessingInfo(){
        return processingInfo;
    }
 
    public void setProcessingInfo(ProcessingInfo value){
        this.processingInfo = value;
    }
 
    @XmlAttribute(name="feeAmount")
    @XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
    @FormParam("feeAmount")
    @IntegerFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    @Min(0)
    public Integer getFeeAmount(){
        return feeAmount;
    }
 
    public void setFeeAmount(Integer value){
        this.feeAmount = value;
    }
 
 
 
}