Package com.google.greaze.definition

Examples of com.google.greaze.definition.ContentBody$Builder


            return createBuilder()
                .setSimpleBody(simpleBodyAdapter.read(reader))
                .build();
          }
          public void write(JsonWriter writer, ContentBody value) throws IOException {
            ContentBody src = (ContentBody) value;
            simpleBodyAdapter.write(writer, src.getSimpleBody());
          }
        };
      case LIST:
        return new TypeAdapter<ContentBody>() {
          @Override
          public ContentBody read(JsonReader reader) throws IOException {
            ContentBody.Builder builder = createBuilder();
            reader.beginArray();
            while (reader.hasNext()) {
              builder.addToListBody(simpleBodyAdapter.read(reader));
            }
            reader.endArray();
            return (ContentBody) builder.build();
          }
          @Override
          public void write(JsonWriter writer, ContentBody value) throws IOException {
            ContentBody src = (ContentBody) value;
            writer.beginArray();
            for(Object entry : src.getListBody()) {
              simpleBodyAdapter.write(writer, entry);
            }
            writer.endArray();
          }
        };
      case MAP:
        return new TypeAdapter<ContentBody>() {
          private final LazyAdapterMap adapters = new LazyAdapterMap(gson, spec);
          @Override
          public ContentBody read(JsonReader reader) throws IOException {
            ContentBody.Builder builder = createBuilder();
            reader.beginObject();
            while (reader.hasNext()) {
              String key = reader.nextName();
              TypeAdapter adapter = adapters.getAdapter(key);
              Object value = adapter.read(reader);
              builder.put(key, value);
            }
            reader.endObject();
            return (CB) builder.build();
          }
          @Override
          public void write(JsonWriter writer, ContentBody value) throws IOException {
            ContentBody src = (ContentBody) value;
            writer.beginObject();
            for(Map.Entry<String, Object> entry : src.entrySet()) {
              String key = entry.getKey();
              TypeAdapter adapter = adapters.getAdapter(key);
              writer.name(key);
              adapter.write(writer, entry.getValue());
            }
View Full Code Here

TOP

Related Classes of com.google.greaze.definition.ContentBody$Builder

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.