package api.unibill.component;
 
import static api.util.ComponentConstants.BOOLEAN_NULL;
import static api.util.ComponentConstants.BOOLEAN_NULL_CODE;
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.Allocation;
import api.util.BooleanFormat;
import api.util.DateFormat;
import api.util.IntegerFormat;
import api.util.LongFormat;
import api.util.StringFormat;
import java.util.Date;
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 2021/05/18
 */
 
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"id", "sourceId", "targetId", "createDate", "isActive", "amount", "targetTransactionType", "causeTransactionId", "causeTransactionType"})
@JsonPropertyOrder({"id", "sourceId", "targetId", "createDate", "isActive", "amount", "targetTransactionType", "causeTransactionId", "causeTransactionType"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(Allocation.class)
public abstract class AbstractAllocation extends UnoComponent<unibill.model.BalancingSummary> {
 
    @FormParam("id")
    @LongFormat
    @DefaultValue(LONG_NULL_CODE)
    protected Long id;
 
    @FormParam("sourceId")
    @LongFormat
    @DefaultValue(LONG_NULL_CODE)
    protected Long sourceId;
 
    @FormParam("targetId")
    @LongFormat
    @DefaultValue(LONG_NULL_CODE)
    protected Long targetId;
 
    @FormParam("createDate")
    @DateFormat
    @DefaultValue(DATE_NULL_CODE)
    protected Date createDate;
 
    @FormParam("isActive")
    @BooleanFormat
    @DefaultValue(BOOLEAN_NULL_CODE)
    protected Boolean isActive;
 
    @FormParam("amount")
    @IntegerFormat
    @DefaultValue(INTEGER_NULL_CODE)
    protected Integer amount;
 
    @FormParam("targetTransactionType")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String targetTransactionType;
 
    @FormParam("causeTransactionId")
    @LongFormat
    @DefaultValue(LONG_NULL_CODE)
    protected Long causeTransactionId;
 
    @FormParam("causeTransactionType")
    @StringFormat
    @DefaultValue(STRING_NULL_CODE)
    protected String causeTransactionType;
 
 
    public AbstractAllocation(){
        super();
        applyDefaults();
    }
 
    public AbstractAllocation(unibill.model.BalancingSummary object){
        super(object);
    }
 
 
    private void applyDefaults() {
        if (!isProxyObject()) {
            id = LONG_NULL;
            sourceId = LONG_NULL;
            targetId = LONG_NULL;
            createDate = DATE_NULL;
            isActive = BOOLEAN_NULL;
            amount = INTEGER_NULL;
            targetTransactionType = STRING_NULL;
            causeTransactionId = LONG_NULL;
            causeTransactionType = 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("allocation: {");
        sb.append("id: ");
        sb.append(id);
        sb.append(',').append(' ');
        sb.append("sourceId: ");
        sb.append(sourceId);
        sb.append(',').append(' ');
        sb.append("targetId: ");
        sb.append(targetId);
        sb.append(',').append(' ');
        sb.append("createDate: ");
        sb.append(createDate);
        sb.append(',').append(' ');
        sb.append("isActive: ");
        sb.append(isActive);
        sb.append(',').append(' ');
        sb.append("amount: ");
        sb.append(amount);
        sb.append(',').append(' ');
        sb.append("targetTransactionType: ");
        sb.append(targetTransactionType);
        sb.append(',').append(' ');
        sb.append("causeTransactionId: ");
        sb.append(causeTransactionId);
        sb.append(',').append(' ');
        sb.append("causeTransactionType: ");
        sb.append(causeTransactionType);
        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;
    }
 
 
    @XmlAttribute(name="sourceId")
    @XmlJavaTypeAdapter(value=api.util.LongAdapter.class, type=Long.class)
    @FormParam("sourceId")
    @LongFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Long getSourceId(){
        return sourceId;
    }
 
 
    @XmlAttribute(name="targetId")
    @XmlJavaTypeAdapter(value=api.util.LongAdapter.class, type=Long.class)
    @FormParam("targetId")
    @LongFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Long getTargetId(){
        return targetId;
    }
 
 
    @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;
    }
 
 
    @XmlAttribute(name="isActive")
    @FormParam("isActive")
    @BooleanFormat
    public Boolean getIsActive(){
        return isActive;
    }
 
 
    @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;
    }
 
 
    @XmlAttribute(name="targetTransactionType")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("targetTransactionType")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getTargetTransactionType(){
        return targetTransactionType;
    }
 
 
    @XmlAttribute(name="causeTransactionId")
    @XmlJavaTypeAdapter(value=api.util.LongAdapter.class, type=Long.class)
    @FormParam("causeTransactionId")
    @LongFormat
    @JsonDeserialize(using=api.util.NumberDeserializer.class)
    public Long getCauseTransactionId(){
        return causeTransactionId;
    }
 
 
    @XmlAttribute(name="causeTransactionType")
    @XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
    @FormParam("causeTransactionType")
    @StringFormat
    @JsonDeserialize(using = api.util.StringDeserializer.class)
    public String getCauseTransactionType(){
        return causeTransactionType;
    }
 
 
 
 
}