package api.unicore.component;
import static api.util.ComponentConstants.BOOLEAN_NULL;
import static api.util.ComponentConstants.BOOLEAN_NULL_CODE;
import static api.util.ComponentConstants.FLOAT_NULL;
import static api.util.ComponentConstants.FLOAT_NULL_CODE;
import static api.util.ComponentConstants.INTEGER_NULL;
import static api.util.ComponentConstants.INTEGER_NULL_CODE;
import static org.codehaus.jackson.map.annotate.JsonSerialize.Inclusion.NON_NULL;
import api.UnoComponent;
import api.unicore.component_manual.MerchantReturnsReserve;
import api.util.BooleanFormat;
import api.util.FloatFormat;
import api.util.IntegerFormat;
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 [Olga Kazmirenko]
* @company UnitedThinkers
* @since 2013/01/29
*/
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"minimumAmount", "requiredAmount", "collectedAmount", "rate", "period", "isEnabled"})
@JsonPropertyOrder({"minimumAmount", "requiredAmount", "collectedAmount", "rate", "period", "isEnabled"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(MerchantReturnsReserve.class)
public abstract class AbstractMerchantReturnsReserve extends UnoComponent<unicore.model.MerchantAccountGroup> {
@FormParam("minimumAmount")
@IntegerFormat
@DefaultValue(INTEGER_NULL_CODE)
protected Integer minimumAmount;
@FormParam("requiredAmount")
@IntegerFormat
@DefaultValue(INTEGER_NULL_CODE)
protected Integer requiredAmount;
@FormParam("collectedAmount")
@IntegerFormat
@DefaultValue(INTEGER_NULL_CODE)
protected Integer collectedAmount;
@FormParam("rate")
@FloatFormat
@DefaultValue(FLOAT_NULL_CODE)
protected Float rate;
@FormParam("period")
@IntegerFormat
@DefaultValue(INTEGER_NULL_CODE)
protected Integer period;
@FormParam("isEnabled")
@BooleanFormat
@DefaultValue(BOOLEAN_NULL_CODE)
protected Boolean isEnabled;
public AbstractMerchantReturnsReserve(){
super();
applyDefaults();
}
public AbstractMerchantReturnsReserve(unicore.model.MerchantAccountGroup object){
super(object);
}
private void applyDefaults() {
if (!isProxyObject()) {
minimumAmount = INTEGER_NULL;
requiredAmount = INTEGER_NULL;
collectedAmount = INTEGER_NULL;
rate = FLOAT_NULL;
period = INTEGER_NULL;
isEnabled = BOOLEAN_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("returns: {");
sb.append("minimumAmount: ");
sb.append(minimumAmount);
sb.append(',').append(' ');
sb.append("requiredAmount: ");
sb.append(requiredAmount);
sb.append(',').append(' ');
sb.append("collectedAmount: ");
sb.append(collectedAmount);
sb.append(',').append(' ');
sb.append("rate: ");
sb.append(rate);
sb.append(',').append(' ');
sb.append("period: ");
sb.append(period);
sb.append(',').append(' ');
sb.append("isEnabled: ");
sb.append(isEnabled);
sb.append('}');
return sb.toString();
}
@XmlAttribute(name="minimumAmount")
@XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
@FormParam("minimumAmount")
@IntegerFormat
@JsonDeserialize(using=api.util.NumberDeserializer.class)
public Integer getMinimumAmount(){
return minimumAmount;
}
public void setMinimumAmount(Integer value){
this.minimumAmount = value;
}
@XmlAttribute(name="requiredAmount")
@XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
@FormParam("requiredAmount")
@IntegerFormat
@JsonDeserialize(using=api.util.NumberDeserializer.class)
public Integer getRequiredAmount(){
return requiredAmount;
}
public void setRequiredAmount(Integer value){
this.requiredAmount = value;
}
@XmlAttribute(name="collectedAmount")
@XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
@FormParam("collectedAmount")
@IntegerFormat
@JsonDeserialize(using=api.util.NumberDeserializer.class)
public Integer getCollectedAmount(){
return collectedAmount;
}
@XmlAttribute(name="rate")
@FormParam("rate")
@FloatFormat
public Float getRate(){
return rate;
}
public void setRate(Float value){
this.rate = value;
}
@XmlAttribute(name="period")
@XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
@FormParam("period")
@IntegerFormat
@JsonDeserialize(using=api.util.NumberDeserializer.class)
public Integer getPeriod(){
return period;
}
public void setPeriod(Integer value){
this.period = value;
}
@XmlAttribute(name="isEnabled")
@FormParam("isEnabled")
@BooleanFormat
public Boolean getIsEnabled(){
return isEnabled;
}
public void setIsEnabled(Boolean value){
this.isEnabled = value;
}
public void audit(AuditHelper helper, ServerObject object) {
unicore.model.MerchantAccountGroup s_object = (unicore.model.MerchantAccountGroup) object;
helper.audit("minimumAmount", minimumAmount, s_object.getReturnReserveMinAmount());
helper.audit("requiredAmount", requiredAmount, s_object.getReturnReserveRequestedAmount());
helper.audit("collectedAmount", collectedAmount, s_object.getReturnReserveCollectedAmount());
helper.audit("rate", rate, s_object.getReturnReserveRate());
helper.audit("period", period, s_object.getReturnReservePeriod());
helper.audit("isEnabled", isEnabled, s_object.getIsReturnReserveEnabled());
}
public static String objectTypeCode(){
return "reserves/returns";
}
}