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.SubscriptionAdjustment;
import api.util.DateFormat;
import api.util.IntegerFormat;
import api.util.LongFormat;
import api.util.StringFormat;
import java.util.Date;
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.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 [Alexander Fliagin]
* @company UnitedThinkers
* @since 2018/09/13
*/
@JsonSerialize(include=NON_NULL)
@XmlType(propOrder={"id", "effectiveDate", "endDate", "note", "type", "length"})
@JsonPropertyOrder({"id", "effectiveDate", "endDate", "note", "type", "length"})
@XmlAccessorType(XmlAccessType.NONE)
@XmlSeeAlso(SubscriptionAdjustment.class)
public abstract class AbstractSubscriptionAdjustment extends UnoComponent<unibill.model.Adjustment> {
@FormParam("id")
@LongFormat
@DefaultValue(LONG_NULL_CODE)
protected Long id;
@FormParam("effectiveDate")
@DateFormat
@DefaultValue(DATE_NULL_CODE)
protected Date effectiveDate;
@FormParam("endDate")
@DateFormat
@DefaultValue(DATE_NULL_CODE)
protected Date endDate;
@FormParam("note")
@StringFormat
@DefaultValue(STRING_NULL_CODE)
protected String note;
@FormParam("type")
@StringFormat
@DefaultValue(STRING_NULL_CODE)
protected String type;
@FormParam("length")
@IntegerFormat
@DefaultValue(INTEGER_NULL_CODE)
protected Integer length;
public AbstractSubscriptionAdjustment(){
super();
applyDefaults();
}
public AbstractSubscriptionAdjustment(unibill.model.Adjustment object){
super(object);
}
private void applyDefaults() {
if (!isProxyObject()) {
id = LONG_NULL;
effectiveDate = DATE_NULL;
endDate = DATE_NULL;
note = STRING_NULL;
type = STRING_NULL;
length = 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("subscription-adjustment: {");
sb.append("id: ");
sb.append(id);
sb.append(',').append(' ');
sb.append("effectiveDate: ");
sb.append(effectiveDate);
sb.append(',').append(' ');
sb.append("endDate: ");
sb.append(endDate);
sb.append(',').append(' ');
sb.append("note: ");
sb.append(note);
sb.append(',').append(' ');
sb.append("type: ");
sb.append(type);
sb.append(',').append(' ');
sb.append("length: ");
sb.append(length);
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="effectiveDate")
@FormParam("effectiveDate")
@DateFormat
@JsonDeserialize(using=api.util.DateDeserializer.class)
public Date getEffectiveDate(){
return effectiveDate;
}
@XmlAttribute(name="endDate")
@FormParam("endDate")
@DateFormat
@JsonDeserialize(using=api.util.DateDeserializer.class)
public Date getEndDate(){
return endDate;
}
@XmlAttribute(name="note")
@XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
@FormParam("note")
@StringFormat
@JsonDeserialize(using = api.util.StringDeserializer.class)
@Size(max = 255)
public String getNote(){
return note;
}
@XmlAttribute(name="type")
@XmlJavaTypeAdapter(value=api.util.StringAdapter.class, type=String.class)
@FormParam("type")
@StringFormat
@JsonDeserialize(using = api.util.StringDeserializer.class)
@Size(max = 1)
public String getType(){
return type;
}
@XmlAttribute(name="length")
@XmlJavaTypeAdapter(value=api.util.IntegerAdapter.class, type=Integer.class)
@FormParam("length")
@IntegerFormat
@JsonDeserialize(using=api.util.NumberDeserializer.class)
public Integer getLength(){
return length;
}
}