Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [che-dev] Properties with type 'any' in DTOs

HI.
Can you answer Vitaly comment in PR?
Sergii Kabashniuk

On Mon, Jun 15, 2015 at 4:12 PM, Sharafy, Tareq <tareq.sharafy@xxxxxxx> wrote:

Hi,

This is an theoretical example of a DTO:

@DTO
interface ExternalCarInfo {
  String getManufacturer();
  void setManufacturer(String v);
  JsonElement getOptions();
  void setOptions(JsonElement v);
}

In this example, I consume a JSON that is defined externally. The external definition states that the 'options' property can be any JSON, arbitrarily nested objects. Allowing the developer to define a property with general type JsonElement will provide a method for consuming the values of the 'options' property. There is no way to do this in Che's DTOs currently and my proposal is possible fix.

thank you
Tareq Sharafy

 

From: che-dev-bounces@xxxxxxxxxxx [mailto:che-dev-bounces@xxxxxxxxxxx] On Behalf Of Sergii Kabashniuk
Sent: Monday 15 June 2015 15:11
To: che developer discussions
Subject: Re: [che-dev] Properties with type 'any' in DTOs

 

Hi

Can you provide some examples of DTO and their usage?

I want to understand your use case more clearly.

 

Sergii Kabashniuk

 

 

On Sun, Jun 14, 2015 at 3:01 PM, Sharafy, Tareq <tareq.sharafy@xxxxxxx> wrote:

Hi,

We are still suggesting improvements to the DTO generator that will improve support for externally defined JSONs. One very common characteristic of several services is defining some properties with type 'any', allowing parts of the data to be transferred as freely structured JSONs. Right now Che's DTO solution doesn't support this feature (Map properties are not sufficient here).

My proposal is to support DTO properties with type JsonElement. The generated deserializer and copy constructor will copy the matching part of the input JSON, and the matching serializer will copy the property's value to the output JSON. The currently generated functions toJson() and fromJsonString(str) create temporary JSONs so I added an internal parameter that prevents redundantly copying JSONs for 'any' properties in these flows.

Please review my pull request for the above proposal or alternatively provide any insights for suggestions:
www.github.com/codenvy/che-core/pull/116

thank you
Tareq Sharafy
Cloud Development Experience | SAP Labs Israel | 15 Hatidhar st, Raanana 43665, Israel
T +972-(0)7-4732-1647 | F +972-(0)9-777-5618


_______________________________________________
che-dev mailing list
che-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/che-dev

 


_______________________________________________
che-dev mailing list
che-dev@xxxxxxxxxxx
To change your delivery options, retrieve your password, or unsubscribe from this list, visit
https://dev.eclipse.org/mailman/listinfo/che-dev



Back to the top