Search in sources :

Example 1 with Error

use of com.yandex.money.api.model.showcase.Showcase.Error in project yandex-money-sdk-java by yandex-money.

the class ShowcaseTypeAdapter method deserialize.

@Override
public Showcase deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException {
    JsonObject object = json.getAsJsonObject();
    Group form = null;
    JsonArray array = object.getAsJsonArray(MEMBER_FORM);
    if (array != null) {
        form = ListDelegate.deserialize(array, context);
    }
    List<AllowedMoneySource> moneySources = context.deserialize(object.get(MEMBER_MONEY_SOURCE), new TypeToken<List<AllowedMoneySource>>() {
    }.getType());
    List<Error> errors = ErrorTypeAdapter.getInstance().fromJson(object.getAsJsonArray(MEMBER_ERROR));
    return new Showcase.Builder().setTitle(getString(object, MEMBER_TITLE)).setHiddenFields(getNotNullMap(object, MEMBER_HIDDEN_FIELDS)).setForm(form).setMoneySources(toEmptyListIfNull(moneySources)).setErrors(toEmptyListIfNull(errors)).create();
}
Also used : JsonArray(com.google.gson.JsonArray) Group(com.yandex.money.api.model.showcase.components.containers.Group) AllowedMoneySource(com.yandex.money.api.model.AllowedMoneySource) TypeToken(com.google.gson.reflect.TypeToken) JsonObject(com.google.gson.JsonObject) JsonUtils.toJsonObject(com.yandex.money.api.typeadapters.JsonUtils.toJsonObject) Error(com.yandex.money.api.model.showcase.Showcase.Error)

Aggregations

JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 TypeToken (com.google.gson.reflect.TypeToken)1 AllowedMoneySource (com.yandex.money.api.model.AllowedMoneySource)1 Error (com.yandex.money.api.model.showcase.Showcase.Error)1 Group (com.yandex.money.api.model.showcase.components.containers.Group)1 JsonUtils.toJsonObject (com.yandex.money.api.typeadapters.JsonUtils.toJsonObject)1