我创建了一个枚举:
public enum ROLECATEGORY {
LOW ("Low Risk", 0),
MEDIUM ("Medium Risk", 1),
public final String attrname;
public final int value;
ROLECATEGORY(String attrname, int value) {
this.attrname = attrname;
this.value = value;
}
public static ROLECATEGORY valueOf(int val){
switch(val){
case 0: return LOW;
case 1: return MEDIUM;
default: throw new IllegalArgumentException("blablabla");
}
}
public int toInt() { return value; }
}
根据入门教程,我创建了普通的 ODataProvider 类。我所缺少的只是将枚举作为属性实例化的 FQDN 类型的代码和平:
CsdlProperty p = new CsdlProperty().setName("MYENUM").setType( ?getEnumType("MYENUM")? )