You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@olingo.apache.org by Manish Java <ma...@gmail.com> on 2018/08/03 04:21:46 UTC

Fwd: How to use @EdmProperty with properties (instead of fields)

I have a class as shown below:


@EdmEntitySet(name = *"Response"*)

@EdmEntityType(name = *"Response"*)

@XmlRootElement(name = *"Response"*)

*class* Response {

    @EdmProperty
    *private* Collection<String> *errors*;


    @JsonProperty(*"Errors"*)

    @XmlElement(name = *"Errors"*)

    *public *Collection<String> getErrors() {

        *return errors*;

    }

    @JsonProperty(*"Status"*)

    @XmlElement(name = *"Status"*)

    *public *String getStatus() {

        return *errors* == null || *errors*.isEmpty()

               ? "OK"
               : "ERROR";
    }
}


As evident, the *getStatus()* method returns a value depending upon the
value of a class field; it is not a simple accessor for a backing field. In
this situation how can *@EdmProperty* be applied to this method, given that
its return value is part of the API? There are many more such methods which
much more complicated logic, so introducing backing fields for each such
method is not an acceptable solution (for us).

Alternatively, can the scope of *@EdmProperty* be expanded to cover
properties as well (currently it can be applied to only to fields)?

I am using Olingo v2.0.10, which is currently the latest version available
from Maven Central.