package api.unicore.component;
import static api.util.ComponentConstants.BOOLEAN_NULL;
import static api.util.ComponentConstants.BOOLEAN_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.MerchantRefundsReserve;
import api.util.BooleanFormat;
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={"requiredAmount", "collectedAmount", "remainingAmount", "isEnabled"})
@JsonPropertyOrder({"requiredAmount", "collectedAmount", "remainingAmount", "isEnabled"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(MerchantRefundsReserve.class)
public abstract class AbstractMerchantRefundsReserve extends UnoComponent<unicore.model.MerchantAccountGroup> {
@FormParam("requiredAmount")
@IntegerFormat
@DefaultValue(INTEGER_NULL_CODE)
protected Integer requiredAmount;
@FormParam("collectedAmount")
@IntegerFormat
@DefaultValue(INTEGER_NULL_CODE)
protected Integer collectedAmount;
@FormParam("remainingAmount")
@IntegerFormat
@DefaultValue(INTEGER_NULL_CODE)
protected Integer remainingAmount;
@FormParam("isEnabled")
@BooleanFormat
@DefaultValue(BOOLEAN_NULL_CODE)
protected Boolean isEnabled;
public AbstractMerchantRefundsReserve(){
super();
applyDefaults();
}
public AbstractMerchantRefundsReserve(unicore.model.MerchantAccountGroup object){
super(object);
}
private void applyDefaults() {
if (!isProxyObject()) {
requiredAmount = INTEGER_NULL;
collectedAmount = INTEGER_NULL;
remainingAmount = 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("refunds: {");
sb.append("requiredAmount: ");
sb.append(requiredAmount);
sb.append(',').append(' ');
sb.append("collectedAmount: ");
sb.append(collectedAmount);
sb.append(',').append(' ');
sb.append("remainingAmount: ");
sb.append(remainingAmount);
sb.append(',').append(' ');
sb.append("isEnabled: ");
sb.append(isEnabled);
sb.append('}');
return sb.toString();
}
@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="remainingAmount")
@XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
@FormParam("remainingAmount")
@IntegerFormat
@JsonDeserialize(using=api.util.NumberDeserializer.class)
public Integer getRemainingAmount(){
return remainingAmount;
}
@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("requiredAmount", requiredAmount, s_object.getRefundReserveRequestedAmount());
helper.audit("collectedAmount", collectedAmount, s_object.getRefundReserveCollectedAmount());
helper.audit("remainingAmount", remainingAmount, s_object.getRefundReserveRemainingAmount());
helper.audit("isEnabled", isEnabled, s_object.getIsRefundReserveEnabled());
}
public static String objectTypeCode(){
return "reserve";
}
}