Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Just got to play with this the other day, and fought it for a few hours, trying <code>@Category</code> methods and others, until I found this: You can create a property of type <code>Splittable</code>, which represents the underlying transport type that has some encoding for booleans/Strings/Lists/Maps. In my case, I know some enveloping type that goes over the wire at design time, and based on some other property, some other field can be any number of other autobeans.</p> <p>You don't even need to know the type of the other bean at compile time, you could get values out using <code>Splittable</code>'s methods, but if using autobeans anyway, it is nice to define the data that is wrapped.</p> <pre><code>interface Envelope { String getStatus(); String getDataType(); Splittable getData(); } </code></pre> <p>(Setters might be desired if you sending data as well as recieving - encoding a bean into a `Splittable to send it in an envelope is even easier than decoding it)</p> <p>The JSON sent over the wire is decoded (probably using <code>AutoBeanCodex</code>) into the <code>Envelope</code> type, and after you've decided what type must be coming out of the <code>getData()</code> method, call something like this to get the nested object out</p> <pre><code>SpecificNestedBean bean = AutoBeanCodex.decode(factory, SpecificNestedBean.class, env.getData()).as(); </code></pre> <p>The <code>Envelope</code> type and the nested types (in <code>factory</code> above) don't even need to be the same <code>AutoBeanFactory</code> type. This could allow you to abstract out the reading/writing of envelopes from the generic transport instance, and use a specific factory for each <code>dataType</code> string property to decode the data's model (and nested models).</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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    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