All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.rschmitt.dynamicobject.EdnTranslator Maven / Gradle / Ivy

There is a newer version: 1.7.3
Show newest version
package com.github.rschmitt.dynamicobject;

import java.io.IOException;
import java.io.StringWriter;
import java.io.Writer;

public interface EdnTranslator {
    /**
     * Read a tagged Edn object as its intended type.
     */
    T read(Object obj);

    /**
     * Return an Edn representation of the given object.
     */
    default String write(T obj) {
        StringWriter stringWriter = new StringWriter();
        write(obj, stringWriter);
        return stringWriter.toString();
    }

    /**
     * Return the tag literal to use during serialization.
     */
    String getTag();

    /**
     * Write an Edn representation of the given object to the given Writer.
     */
    default void write(T obj, Writer writer) {
        try {
            writer.write(write(obj));
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy