Serialization { private Yaml yaml() { return this.cachedYaml.get(); } private  Serialization(@Nullable Void v); CommentsManager getCommentsManager(); void addTrueValues(String... strings); void addFalseValues(String... strings); static Serialization getGlobal(); void cleanup(); void cleanupThread(); @Nullable @SuppressWarnings({"unchecked", "rawtypes"}) StringSerializer<T> registerStringSerializable(Class<T> clazz); @SuppressWarnings("unchecked") void registerStringSerializer(StringSerializer<T> stringSerializer); @SuppressWarnings({"unchecked", "rawtypes"}) void registerSerializable(Class<T> clazz); @Nullable @SuppressWarnings("unchecked") Serializer<T> registerSerializer(Serializer<T> serializer); boolean isStringSerializable(Object object); boolean isStringSerializable(Class<?> clazz); boolean isSerializable(Object object); boolean isSerializable(Class<?> clazz); @SuppressWarnings("unchecked") String serializeToString(Class<T> type, T object); @SuppressWarnings("unchecked") T deserializeFromString(Class<T> type, String str); @SuppressWarnings("unchecked") String serializeToString(Object object); JsonElement toJsonTree(Object src); JsonElement toJsonTree(Object src, Type typeOfSrc); String toJson(Object src); String toJson(Object src, Type typeOfSrc); void toJson(Object src, Appendable writer); void toJson(Object src, Type typeOfSrc, Appendable writer); void toJson(Object src, Type typeOfSrc, JsonWriter writer); String toJson(JsonElement jsonElement); void toJson(JsonElement jsonElement, Appendable writer); JsonWriter newJsonWriter(Writer writer); JsonReader newJsonReader(Reader reader); void toJson(JsonElement jsonElement, JsonWriter writer); T fromJson(String json, Class<T> classOfT); T fromJson(String json, Type typeOfT); T fromJson(Reader json, Class<T> classOfT); T fromJson(Reader json, Type typeOfT); T fromJson(JsonReader reader, Type typeOfT); T fromJson(JsonElement json, Class<T> classOfT); T fromJson(JsonElement json, Type typeOfT); String toYamlWithComments(Object data); String toYamlWithComments(Object data, DocumentComments comments); Node toYamlNode(@Nullable Object data); String toYaml(Object data); String toYaml(Iterator<?> data); void toYaml(Object data, Writer output); void toYamlWithComments(Object data, Writer output); void toYamlWithComments(Object data, Writer output, DocumentComments comments); void toYaml(Iterator<?> data, Writer output); String toYaml(Object data, Tag rootTag, @Nullable FlowStyle flowStyle); String toYamlAsMap(Object data); @Nullable T fromYamlNode(Node node); T fromYamlNode(Node node, Class<T> type); Object fromYaml(String yaml); Object fromYaml(InputStream io); Object fromYaml(Reader io); T fromYaml(ConfigTemplate<T> template, Reader io); T fromYaml(Reader io, Class<T> type); T fromYaml(String yaml, Class<T> type); T fromYaml(InputStream input, Class<T> type); Iterable<Object> fromAllYaml(Reader yaml); Iterable<Object> fromAllYaml(String yaml); Iterable<Object> fromAllYaml(InputStream yaml);  }
@Test public void yamlTest() { Serialization global = prepareSerialization(); EntityStorage entityStorage = prepareObject(); System.out.println("[YAML] Deserializing javabean: \n"); { String toYaml = global.toYaml(entityStorage.beanObject); System.out.println(toYaml); Assert.assertEquals(entityStorage.beanObject, global.fromYaml(toYaml, BeanObject.class)); } System.out.println("\n[YAML] Deserializing object: \n" + entityStorage + "\n"); String toYaml = global.toYaml(entityStorage); System.out.println(toYaml); System.out.println(); EntityStorage storage = global.fromYaml(toYaml, EntityStorage.class); System.out.println("\n[YAML] Deserialized object: \n" + storage); Assert.assertEquals(entityStorage.toString(), storage.toString()); Assert.assertEquals(entityStorage, storage); System.out.println("\n[YAML] Objects equals!"); }