Class YamlLikeObjectTypeAdapter
- Direct Known Subclasses:
- BukkitAwareObjectTypeAdapter
TypeAdapter.
 
 Bukkit's serialization API is built around Yaml, and specifically SnakeYaml. Objects that are
 deserialized via Bukkit's serialization API may have strict expectations regarding the types of
 data they encounter during deserialization. This also applies to some of Bukkit's built-in
 serializable types, such as ItemMeta. For compatibility reasons, this TypeAdapter is
 supposed to produce types that more closely match those produced by SnakeYaml. Most notable
 differences to Gson's default types are:
 
- We produce LinkedHashMap's instead of Gson's LinkedTreeMap.
- We delegate the parsing of numbers to SnakeYaml, which produces integers, longs, or BigInteger for whole numbers and doubles for fractional numbers, whereas Gson always produces doubles by default.
- Gson represents special numbers like Double.NaNor infinities as Strings, but doesn't automatically return them as double anymore. We check if a loaded String can be parsed as one of these special numbers, and then return this number instead.
Gson does not allow the default Object TypeAdapter to be overridden. This TypeAdapter therefore has to be explicitly invoked whenever it is supposed to be used.
 Another alternative could be to deserialize objects from Json via a Yaml parser: In principle,
 since Json is supposed to be a subset of Yaml, this should work. However, there is no guarantee
 that the produced Json actually conforms to standard Json: For instance, Json does not support
 special numbers like Double.NaN or infinities. Their representation is therefore specific
 to the used Json generator and there is no guarantee that a certain Yaml parser is then able to
 parse those numbers correctly.
 
 There are further limitations that make Json less suited for the serialization of
 ConfigurationSerializables: See
 BukkitAwareObjectTypeAdapter.
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryMethods inherited from class com.google.gson.TypeAdapterfromJson, fromJson, fromJsonTree, nullSafe, toJson, toJson, toJsonTree
- 
Field Details- 
FACTORYpublic static final com.google.gson.TypeAdapterFactory FACTORY
 
- 
- 
Constructor Details- 
YamlLikeObjectTypeAdapterprotected YamlLikeObjectTypeAdapter(com.google.gson.Gson gson) 
 
- 
- 
Method Details- 
create
- 
read- Specified by:
- readin class- com.google.gson.TypeAdapter<Object>
- Throws:
- IOException
 
- 
writepublic void write(@Nullable com.google.gson.stream.JsonWriter out, @Nullable Object value) throws IOException - Specified by:
- writein class- com.google.gson.TypeAdapter<Object>
- Throws:
- IOException
 
 
-