@@ -0,0 +1,3401 @@
+package com.google.tripmeout.frontend.serialization;%0A%0Aimport com.google.appengine.repackaged.com.google.api.client.json.Json;%0Aimport com.google.common.base.Strings;%0Aimport com.google.gson.JsonParseException;%0Aimport com.google.gson.TypeAdapter;%0Aimport com.google.gson.stream.JsonReader;%0Aimport com.google.gson.stream.JsonToken;%0Aimport com.google.gson.stream.JsonWriter;%0Aimport java.io.IOException;%0Aimport com.google.tripmeout.frontend.TripModel;%0A%0A%0Apublic class GsonTripModelTypeAdapter extends TypeAdapter%3CTripModel%3E %7B%0A    %0A    private static final String TRIP_MODEL_ID_JSON_FIELD_NAME = %22id%22;%0A    private static final String TRIP_MODEL_NAME_JSON_FIELD_NAME = %22name%22;%0A    private static final String TRIP_MODEL_USER_ID_JSON_FIELD_NAME = %22userId%22;%0A    private static final String TRIP_MODEL_LATITUDE_JSON_FIELD_NAME = %22locationLat%22;%0A    private static final String TRIP_MODEL_LONGITUDE_JSON_FIELD_NAME = %22locationLong%22;%0A%0A    @Override%0A    public TripModel read(JsonReader reader) throws IOException%7B%0A%0A        if(reader.peek() == JsonToken.NULL)%7B%0A            reader.nextNull();%0A            return null;%0A        %7D%0A        TripModel.Builder tripBuilder = TripModel.builder();%0A        reader.beginObject();%0A        while(reader.hasNext())%7B%0A            JsonToken token = reader.peek();%0A            if(token.equals(JsonToken.NAME))%7B%0A                String name = reader.nextName();%0A                switch(name)%7B%0A                    case TRIP_MODEL_ID_JSON_FIELD_NAME:%0A                    tripBuilder.setId(reader.nextString());%0A                    break;%0A                    case TRIP_MODEL_NAME_JSON_FIELD_NAME:%0A                    tripBuilder.setName(reader.nextString());%0A                    break;%0A                    case TRIP_MODEL_USER_ID_JSON_FIELD_NAME:%0A                    tripBuilder.setUserId(reader.nextString());%0A                    break;%0A                    case TRIP_MODEL_LATITUDE_JSON_FIELD_NAME:%0A                    tripBuilder.setLocationLat(reader.nextDouble());%0A                    break;%0A                    case TRIP_MODEL_LONGITUDE_JSON_FIELD_NAME:%0A                    tripBuilder.setLocationLong(reader.nextDouble());%0A                    break;%0A                    default:%0A                    throw new JsonParseException(%0A                        String.format(%22Unknown field name %25s for type Trip Model%22, name));%0A                %7D%0A            %7D%0A        %7D%0A        reader.endObject();%0A        return tripBuilder.build();%0A%0A    %7D%0A%0A    @Override%0A    public void write(JsonWriter writer, TripModel trip) throws IOException%7B%0A        if(trip == null)%7B%0A            writer.nullValue();%0A            return;%0A        %7D%0A        writer.beginObject();%0A        writeUnlessNullOrEmpty(writer,TRIP_MODEL_ID_JSON_FIELD_NAME,trip.id());%0A        writeUnlessNullOrEmpty(writer, TRIP_MODEL_NAME_JSON_FIELD_NAME, trip.name());%0A        writeUnlessNullOrEmpty(writer, TRIP_MODEL_LATITUDE_JSON_FIELD_NAME, trip.locationLat());%0A        writer.endObject();%0A    %7D%0A%0A     private static void writeUnlessNullOrEmpty(JsonWriter writer, String name, String value)%0A      throws IOException %7B%0A    if (Strings.isNullOrEmpty(value)) %7B%0A      writer.name(name);%0A      writer.value(value);%0A    %7D%0A  %7D%0A%0A  private static void writeUnlessNullOrEmpty(JsonWriter writer, String name, Double value)%0A      throws IOException %7B%0A    if (Strings.isNullOrEmpty(value)) %7B%0A      writer.name(name);%0A      writer.value(value);%0A    %7D%0A  %7D%0A%0A%7D

create Gson Trip Model type adapter