0

I want to have a simple generic Entity interface pretty much like a map such as on client side in a Gwt + GwtQuery project .

public interface Entity extends JsonBuilder {

    public String JsonObject getProperty(String property) ;

    public Entity setProperty(String name , JsonObject obj ) ;

    public String getPropertyType(String property) /* returns the actual 

}

I want to be able to convert any pojo on server side to a Map form along with some type info and retrieve it on client as an Entity. Entities can be nested.

Is this doable ?

If yes. Please give some detailed guidelines.

To clarify further my goal is to have a single generic Entity interface that is capable of representing varied/diverse types of pojos from server. The type information of such a dynamic entity is expected to be available on the client side as a separate entity.

Do you think the code below will work and serve my purpose ? If yes - how will the json text underneath look like ?

        public interface Tuple extends JsonBuilder {

           public JsonValue get(String name);

           public void set(String name, JsonValue ser);

   }

   public interface Entity extends Tuple {

           public String getType();

           public Tuple[] getTuples();

   }
Gautam
  • 1,030
  • 13
  • 37
  • Please see my code as an idea. I am looking for the actual solution. So if you think my code is useless please simply suggest the alternative. – Gautam Dec 01 '14 at 14:11
  • What is JsonObject in server and client sides? – Manolo Carrasco Moñino Feb 21 '15 at 08:17
  • @ManoloCarrascoMoñino I have a generic Map that can contain random entities and I will be passing it to client side . I would like to retrieve such entities as Json objects on client side. Did I get your question right ? – Gautam Feb 23 '15 at 09:01
  • JsonObject is a class from Json library like Jackson or Gson.. I think it can represent any type of Json value object.. not sure if its the right idea though. I haven't used Json much. Possibly it should be JsonValue.. – Gautam Feb 23 '15 at 09:03

0 Answers0