Subversion Repositories bacoAlunos

Rev

Rev 1729 | Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed

package pt.estgp.estgweb.domain;

import com.owlike.genson.Genson;
import com.owlike.genson.TransformationException;
import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.io.Serializable;
import java.util.ArrayList;

/**
 * Created by jorgemachado on 13/04/17.
 */

public class ConfigurationSeparatorImpl extends ConfigurationSeparator {
    @1.5.0/docs/api/java/lang/Override.html">Override
    public 1.5.0/docs/api/java/io/Serializable.html">Serializable getSerializable()
    {
        return getId();
    }

    static Genson confGenson = new Genson.Builder()
            .exclude(5+0%2Fdocs%2Fapi+Object">Object.class)
            .include(1.5.0/docs/api/java/lang/String.html">String.class)
            //todo
            .create();

    public 1.5.0/docs/api/java/lang/String.html">String getJson() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException
    {
        return confGenson.serialize(this);
    }

    public static 1.5.0/docs/api/java/lang/String.html">String getJson(ArrayList<ConfigurationSeparatorImpl> seps) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException
    {
        return confGenson.serialize(seps);
    }

    public static ConfigurationSeparatorImpl loadFromJson(1.5.0/docs/api/java/lang/String.html">String json) throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException {
        return confGenson.deserialize(json, ConfigurationSeparatorImpl.class);
    }

    public JSONObject getJsonObject() throws 1.5.0/docs/api/java/io/IOException.html">IOException, TransformationException, JSONException {
        return new JSONObject(getJson());
    }
}