Example usage for com.google.gson GsonBuilder create

List of usage examples for com.google.gson GsonBuilder create

Introduction

In this page you can find the example usage for com.google.gson GsonBuilder create.

Prototype

public Gson create() 

Source Link

Document

Creates a Gson instance based on the current configuration.

Usage

From source file:com.ccc.crest.core.cache.crest.schema.option.AcceptType.java

License:Open Source License

@Override
public AcceptType deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
        throws JsonParseException {
    Iterator<Entry<String, JsonElement>> objectIter = ((JsonObject) json).entrySet().iterator();
    while (objectIter.hasNext()) {
        Entry<String, JsonElement> objectEntry = objectIter.next();
        String key = objectEntry.getKey();
        JsonElement value = objectEntry.getValue();
        if (AcceptDumpKey.equals(key)) {
            CcpType schemaTypeElement = new CcpType(key);
            GsonBuilder gson = new GsonBuilder();
            gson.registerTypeAdapter(CcpType.class, schemaTypeElement);
            ccpType = gson.create().fromJson(value.getAsString(), CcpType.class);
        } else if (AcceptNameKey.equals(key))
            name = value.getAsString();/*from   ww  w. j a v a2  s .co  m*/
        else
            LoggerFactory.getLogger(getClass())
                    .warn(key + " has a field not currently being handled: \n" + objectEntry.toString());
    }
    return this;
}

From source file:com.ccc.crest.core.cache.crest.schema.option.CrestOptions.java

License:Open Source License

public static Future<EveData> getFuture(String url, boolean doGet, CrestResponseCallback callback)
        throws Exception {
    if (url == null)
        url = getUrl();/*from w w  w .  jav a  2  s.  com*/
    GsonBuilder gson = new GsonBuilder();
    gson.registerTypeAdapter(CrestOptions.class, new CrestOptions(doGet));
    //@formatter:off
    CrestRequestData rdata = new CrestRequestData(null, url, gson.create(), null, CrestOptions.class, callback,
            ReadScope, getVersion(VersionType.Get), continueRefresh, true);
    //@formatter:on
    if (doGet)
        return CrestController.getCrestController().crestClient.getCrest(rdata);
    return CrestController.getCrestController().crestClient.getOptions(rdata);
}

From source file:com.ccc.crest.core.cache.crest.schema.RootEndpoint.java

License:Open Source License

public void dumpTree(File fbase) throws Exception {
    AtomicInteger level = new AtomicInteger(-2);
    traverse(endpoints.root, fbase, level);

    String path = fbase.getPath() + "/root/" + "technical.md";
    PrintWriter out = new PrintWriter(path);
    out.println(techPage);/*from   w  ww.  j  ava  2  s  . c  o  m*/
    out.close();
    GsonBuilder gson = new GsonBuilder();
    gson.setPrettyPrinting();
    jsonStr = gson.create().toJson(endpoints);
    log.info("\n" + jsonStr + "\n");
    log.info("\ntotalGroups: " + totalGroups.get() + "\ntotalLeafs: " + totalLeafs.get() + "\ntotalUids: "
            + totalUids.get());
}

From source file:com.ccc.crest.core.cache.crest.sovereignty.SovCampaignsCollection.java

License:Open Source License

public static Future<EveData> getFuture(CrestResponseCallback callback) throws Exception {
    GsonBuilder gson = new GsonBuilder();
    gson.registerTypeAdapter(SovCampaignsCollection.class, new SovCampaignsCollection());
    //@formatter:off
    CrestRequestData rdata = new CrestRequestData(null, getUrl(), gson.create(), null,
            SovCampaignsCollection.class, callback, ReadScope, getVersion(VersionType.Get), continueRefresh);
    //@formatter:on
    return CrestController.getCrestController().crestClient.getCrest(rdata);
}

From source file:com.ccc.crest.core.cache.crest.sovereignty.SovStructureCollection.java

License:Open Source License

public static Future<EveData> getFuture(CrestResponseCallback callback) throws Exception {
    GsonBuilder gson = new GsonBuilder();
    gson.registerTypeAdapter(SovStructureCollection.class, new SovStructureCollection());
    //@formatter:off
    CrestRequestData rdata = new CrestRequestData(null, getUrl(), gson.create(), null,
            SovStructureCollection.class, callback, ReadScope, getVersion(VersionType.Get), continueRefresh);
    //@formatter:on
    return CrestController.getCrestController().crestClient.getCrest(rdata);
}

From source file:com.ccc.crest.core.cache.crest.tournament.TournamentBanCollection.java

License:Open Source License

public static Future<EveData> getFuture(CrestResponseCallback callback) throws Exception {
    GsonBuilder gson = new GsonBuilder();
    gson.registerTypeAdapter(TournamentBanCollection.class, new TournamentBanCollection());

    //@formatter:off
    CrestRequestData rdata = new CrestRequestData(null, getUrl(), gson.create(), null,
            TournamentBanCollection.class, callback, ReadScope, getVersion(VersionType.Get), continueRefresh,
            false);//from ww w.j ava 2s .c  o m
    //@formatter:on
    return CrestController.getCrestController().crestClient.getCrest(rdata);
}

From source file:com.ccc.crest.core.cache.crest.tournament.TournamentCollection.java

License:Open Source License

public static Future<EveData> getFuture(CrestResponseCallback callback) throws Exception {
    GsonBuilder gson = new GsonBuilder();
    gson.registerTypeAdapter(TournamentCollection.class, new TournamentCollection());

    //@formatter:off
    CrestRequestData rdata = new CrestRequestData(null, getUrl(), gson.create(), null,
            TournamentCollection.class, callback, ReadScope, getVersion(VersionType.Get), continueRefresh,
            false);/*  ww  w  .j a  v a 2  s.c o m*/
    //@formatter:on
    return CrestController.getCrestController().crestClient.getCrest(rdata);
}

From source file:com.ccc.crest.core.cache.crest.tournament.TournamentMatchCollection.java

License:Open Source License

public static Future<EveData> getFuture(long tournamentId, CrestResponseCallback callback) throws Exception {
    String url = getUrl();//  w w w . ja  v a  2 s.  co m
    url += tournamentId + "/matches/";
    GsonBuilder gson = new GsonBuilder();
    gson.registerTypeAdapter(TournamentMatchCollection.class, new TournamentMatchCollection());
    //@formatter:off
    CrestRequestData rdata = new CrestRequestData(null, url, gson.create(), null,
            TournamentMatchCollection.class, callback, ReadScope, getVersion(VersionType.Get), continueRefresh,
            false);
    //@formatter:on
    return CrestController.getCrestController().crestClient.getCrest(rdata);
}

From source file:com.ccc.crest.core.cache.crest.tournament.TournamentMatchElement.java

License:Open Source License

public static Future<EveData> getFuture(CrestResponseCallback callback) throws Exception {
    GsonBuilder gson = new GsonBuilder();
    gson.registerTypeAdapter(TournamentMatchElement.class, new TournamentMatchElement());

    //@formatter:off
    CrestRequestData rdata = new CrestRequestData(null, getUrl(), gson.create(), null,
            TournamentMatchElement.class, callback, ReadScope, getVersion(VersionType.Get), continueRefresh,
            false);/*ww  w  .j a  va2 s. c o  m*/
    //@formatter:on
    return CrestController.getCrestController().crestClient.getCrest(rdata);
}

From source file:com.ccc.crest.core.cache.crest.tournament.TournamentMatchFrame.java

License:Open Source License

public static Future<EveData> getFuture(CrestResponseCallback callback) throws Exception {
    GsonBuilder gson = new GsonBuilder();
    gson.registerTypeAdapter(TournamentMatchFrame.class, new TournamentMatchFrame());

    //@formatter:off
    CrestRequestData rdata = new CrestRequestData(null, getUrl(), gson.create(), null,
            TournamentMatchFrame.class, callback, ReadScope, getVersion(VersionType.Get), continueRefresh,
            false);/*from   ww w . j a va  2s . co m*/
    //@formatter:on
    return CrestController.getCrestController().crestClient.getCrest(rdata);
}