How to create an enum entity type in Olingo OData V4 java API

Viewed 1203

I have created an enumeration:

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; }
}

According to the starter tutorial I've created the normal ODataProvider Class. All I'm missing is a peace of code to get the enum as FQDN type for the property instantiation:

CsdlProperty p = new CsdlProperty().setName("MYENUM").setType( ?getEnumType("MYENUM")? )
1 Answers
Related