Search in sources :

Example 1 with PortConfigListTypeAdaptor

use of com.cloud.agent.transport.Request.PortConfigListTypeAdaptor in project cloudstack by apache.

the class GsonHelper method setDefaultGsonConfig.

static Gson setDefaultGsonConfig(GsonBuilder builder) {
    builder.setVersion(1.5);
    InterfaceTypeAdaptor<DataStoreTO> dsAdaptor = new InterfaceTypeAdaptor<DataStoreTO>();
    builder.registerTypeAdapter(DataStoreTO.class, dsAdaptor);
    InterfaceTypeAdaptor<DataTO> dtAdaptor = new InterfaceTypeAdaptor<DataTO>();
    builder.registerTypeAdapter(DataTO.class, dtAdaptor);
    ArrayTypeAdaptor<Command> cmdAdaptor = new ArrayTypeAdaptor<Command>();
    builder.registerTypeAdapter(Command[].class, cmdAdaptor);
    ArrayTypeAdaptor<Answer> ansAdaptor = new ArrayTypeAdaptor<Answer>();
    builder.registerTypeAdapter(Answer[].class, ansAdaptor);
    builder.registerTypeAdapter(new TypeToken<List<PortConfig>>() {
    }.getType(), new PortConfigListTypeAdaptor());
    builder.registerTypeAdapter(new TypeToken<Pair<Long, Long>>() {
    }.getType(), new NwGroupsCommandTypeAdaptor());
    Gson gson = builder.create();
    dsAdaptor.initGson(gson);
    dtAdaptor.initGson(gson);
    cmdAdaptor.initGson(gson);
    ansAdaptor.initGson(gson);
    return gson;
}
Also used : DataStoreTO(com.cloud.agent.api.to.DataStoreTO) InterfaceTypeAdaptor(com.cloud.agent.transport.InterfaceTypeAdaptor) Gson(com.google.gson.Gson) NwGroupsCommandTypeAdaptor(com.cloud.agent.transport.Request.NwGroupsCommandTypeAdaptor) Answer(com.cloud.agent.api.Answer) DataTO(com.cloud.agent.api.to.DataTO) PortConfigListTypeAdaptor(com.cloud.agent.transport.Request.PortConfigListTypeAdaptor) Command(com.cloud.agent.api.Command) TypeToken(com.google.gson.reflect.TypeToken) ArrayTypeAdaptor(com.cloud.agent.transport.ArrayTypeAdaptor) PortConfig(com.cloud.agent.api.SecStorageFirewallCfgCommand.PortConfig)

Aggregations

Answer (com.cloud.agent.api.Answer)1 Command (com.cloud.agent.api.Command)1 PortConfig (com.cloud.agent.api.SecStorageFirewallCfgCommand.PortConfig)1 DataStoreTO (com.cloud.agent.api.to.DataStoreTO)1 DataTO (com.cloud.agent.api.to.DataTO)1 ArrayTypeAdaptor (com.cloud.agent.transport.ArrayTypeAdaptor)1 InterfaceTypeAdaptor (com.cloud.agent.transport.InterfaceTypeAdaptor)1 NwGroupsCommandTypeAdaptor (com.cloud.agent.transport.Request.NwGroupsCommandTypeAdaptor)1 PortConfigListTypeAdaptor (com.cloud.agent.transport.Request.PortConfigListTypeAdaptor)1 Gson (com.google.gson.Gson)1 TypeToken (com.google.gson.reflect.TypeToken)1