Class AutoBeanCodex
- java.lang.Object
-
- com.google.web.bindery.autobean.shared.AutoBeanCodex
-
public class AutoBeanCodex extends java.lang.Object
Utility methods for encoding an AutoBean graph into a JSON-compatible string. This codex intentionally does not preserve object identity, nor does it encode cycles, but it will detect them.
-
-
Constructor Summary
Constructors Constructor Description AutoBeanCodex()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> AutoBean<T>
decode(AutoBeanFactory factory, java.lang.Class<T> clazz, Splittable data)
Decode an AutoBeanCodex payload.static <T> AutoBean<T>
decode(AutoBeanFactory factory, java.lang.Class<T> clazz, java.lang.String payload)
Decode an AutoBeanCodex payload.static void
decodeInto(Splittable data, AutoBean<?> bean)
Copy data from aSplittable
into an AutoBean.static Splittable
encode(AutoBean<?> bean)
Encodes an AutoBean.
-
-
-
Method Detail
-
decode
public static <T> AutoBean<T> decode(AutoBeanFactory factory, java.lang.Class<T> clazz, Splittable data)
Decode an AutoBeanCodex payload.- Type Parameters:
T
- the expected return type- Parameters:
factory
- an AutoBeanFactory capable of producingAutoBean<T>
clazz
- the expected return typedata
- a payload previously generated byencode(AutoBean)
- Returns:
- an AutoBean containing the payload contents
-
decode
public static <T> AutoBean<T> decode(AutoBeanFactory factory, java.lang.Class<T> clazz, java.lang.String payload)
Decode an AutoBeanCodex payload.- Type Parameters:
T
- the expected return type- Parameters:
factory
- an AutoBeanFactory capable of producingAutoBean<T>
clazz
- the expected return typepayload
- a payload string previously generated byencode(AutoBean)
.getPayload()
.- Returns:
- an AutoBean containing the payload contents
-
decodeInto
public static void decodeInto(Splittable data, AutoBean<?> bean)
Copy data from aSplittable
into an AutoBean. Unset values in the Splittable will not nullify data that already exists in the AutoBean.- Parameters:
data
- the source data to copybean
- the target AutoBean
-
encode
public static Splittable encode(AutoBean<?> bean)
Encodes an AutoBean. The actual payload contents can be retrieved throughSplittable.getPayload()
.- Parameters:
bean
- the bean to encode- Returns:
- a Splittable that encodes the state of the AutoBean
-
-