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.MerchantChargebacksReserve;
import api.util.BooleanFormat;
import api.util.FloatFormat;
import api.util.IntegerFormat;
import iapp.services.ServerObject;
import iapp.util.audit.AuditHelper;
import javax.validation.constraints.Min;
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;
import unipay.validator.CustomValidator;
/**
* @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(MerchantChargebacksReserve.class)
@CustomValidator
public abstract class AbstractMerchantChargebacksReserve 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 AbstractMerchantChargebacksReserve(){
super();
applyDefaults();
}
public AbstractMerchantChargebacksReserve(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("chargebacks: {");
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
@Min(0)
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.getChargebackReserveMinAmount());
helper.audit("requiredAmount", requiredAmount, s_object.getChargebackReserveRequestedAmount());
helper.audit("collectedAmount", collectedAmount, s_object.getChargebackReserveCollectedAmount());
helper.audit("rate", rate, s_object.getChargebackReserveRate());
helper.audit("period", period, s_object.getChargebackReservePeriod());
helper.audit("isEnabled", isEnabled, s_object.getIsChargebackReserveEnabled());
}
public static String objectTypeCode(){
return "reserves/chargebacks";
}
}