public class Descriptor extends Object
When the original object has complicated inner structure and there is a requirement to send it over the wire,
it's a time to define a corresponding Descriptor becomes. In this case, the Descriptor can just
have minimal information enough to construct the original object on the other side of the wire
When the cost to instantiate the complete original object is high, for example, network calls are required, but
the use cases are limited to the identification properties, define a corresponding Descriptor becomes
handy
| Modifier and Type | Field and Description |
|---|---|
static com.google.gson.Gson |
GSON
Use gson for ser/de
|
| Constructor and Description |
|---|
Descriptor() |
| Modifier and Type | Method and Description |
|---|---|
Descriptor |
copy() |
static Descriptor |
fromJson(String json)
Deserialize the json string to the a
Descriptor object |
static <T extends Descriptor> |
fromJson(String json,
Class<T> clazz)
Deserialize the json string to the specified
Descriptor object |
static List<Descriptor> |
fromJsonList(String jsonList)
Deserialize the string, resulted from
toJson(List), to a list of descriptors |
static String |
toJson(Descriptor descriptor)
Serialize any
Descriptor object as json string |
static String |
toJson(List<Descriptor> descriptors)
Serialize a list of descriptors as json string
|
String |
toString() |
public Descriptor copy()
public static String toJson(Descriptor descriptor)
Descriptor object as json string
Note: it can serialize subclasses
public static Descriptor fromJson(String json)
Descriptor objectpublic static <T extends Descriptor> T fromJson(String json, Class<T> clazz)
Descriptor objectpublic static String toJson(List<Descriptor> descriptors)
public static List<Descriptor> fromJsonList(String jsonList)
toJson(List), to a list of descriptors