Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Ok Now the requirement is clear and here is the solution</p> <p>define your operations</p> <pre><code>enum MyOperator { AND, OR } </code></pre> <p>Write a class to hold you atomic operaton</p> <pre><code>class AtomicOperation { Object lhs; Object rhs; MyOperator operator; } </code></pre> <p>Now if You want something like (Year:another values OR (Report:some valeus AND Citation:some valeues))</p> <p>your JSON should look like :</p> <pre><code>String jsonString = {{Year:['2001','2002']} OR {{Report:['Report1']} AND {Citation:['Citation1']}}} </code></pre> <p>So First Cast this JSON to AtominOperation class using the code</p> <pre><code>ConvertJsonToObject.getFromJSON(jsonString,AtominOperation.class); GSON will cast it to a Simple AtominOperation Object with operation "OR" and lhs,rhs as 2 LinkedHashMaps (Default behaviour of GSON) Now use the below method to get the proper AtomicOperation Object from the above AtomicOperation Object. public static AtomicOperation deriveFromJSON(AtomicOperation operation) { if (operation.getLhs().getClass().equals(LinkedHashMap.class)) { AtomicOperation leftOperation = deriveFromJSON(ConvertJsonToObject .getFromJSON(ConvertJsonToObject.toJSON(operation.getLhs()), AtomicOperation.class)); AtomicOperation rightOperation = deriveFromJSON(ConvertJsonToObject .getFromJSON(ConvertJsonToObject.toJSON(operation.getRhs()), AtomicOperation.class)); return new AtomicOperation(leftOperation, operation.getOperator(), rightOperation); } return operation; } </code></pre> <p>The Final AtomicOperation Object would be what u want. :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload