Пример #1
0
    private SegmentBlock deserializeBlock(JsonObject json, JsonDeserializationContext context) {
      if (!json.has("actions")) {
        throw new ProtectionParseException("Missing actions identifier");
      }
      SegmentBlock segment = new SegmentBlock();
      segment.types.addAll(
          deserializeAsArray(
              json.get("actions"),
              context,
              new TypeToken<BlockType>() {},
              new TypeToken<List<BlockType>>() {}.getType()));
      json.remove("actions");

      if (json.has("meta")) {
        segment.meta = json.get("meta").getAsInt();
        json.remove("meta");
      }

      if (json.has("clientUpdate")) {
        segment.clientUpdate =
            new ClientBlockUpdate(
                (Volume)
                    context.deserialize(
                        json.get("clientUpdate").getAsJsonObject().get("coords"), Volume.class));
        json.remove("clientUpdate");
      }

      return segment;
    }