package com.lfo.vo;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSubTypes;
import com.fasterxml.jackson.annotation.JsonSubTypes.Type;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.annotation.JsonTypeInfo.As;
import com.lfo.suntone.db.CanGetName;
@JsonTypeInfo(use = JsonTypeInfo.Id.CLASS, include = As.PROPERTY, property = "@class")
@JsonSubTypes({
@Type(value = CommercialOutput.class, name = "CommercialOutput"),
@Type(value = ConsumptionOfRawMaterials.class, name = "ConsumptionOfRawMaterials") ,
@Type(value = ConsumptionOfWrapper.class, name = "ConsumptionOfWrapper") ,
@Type(value = SellingOut.class, name = "SellingOut")
})
public abstract class ManageItemOperationText implements CanGetName {
/*
產出商品commercial output
消耗原料consumption of raw materials
包裝消耗consumption of wrapper
賣出產品 selling-out
*/
//private int id=0;
//private String name="";
public String commercialOutput=" 產出商品";
public String consumptionOfRawMaterials="消耗原料";
public String consumptionOfWrapper="包裝消耗";
public String sellingOut="賣出產品";
/*
public Integer getId() {
return id;
}
public String getName() {
return name;
}
*/
}
package com.lfo.vo;
public class CommercialOutput extends ManageItemOperationText {
private int id=0;
private String name=super.commercialOutput;//"產出商品";
@Override
public String getName() {
return this.name;
}
@Override
public Integer getId() {
return this.id;
}
}
http://wiki.fasterxml.com/JacksonPolymorphicDeserialization
http://codelife.me/blog/2012/11/03/jackson-polymorphic-deserialization/
https://nickebbitt.wordpress.com/2014/01/31/handling-polymorphic-types-using-jackson-framework-for-json/
沒有留言:
張貼留言