Package com.google.greaze.definition.internal.utils

Examples of com.google.greaze.definition.internal.utils.FieldNavigator


    }
    try {
      UrlParams.Builder paramsBuilder = new UrlParams.Builder(spec);
      if (spec.hasParamsObject()) {
        Type paramType = spec.getType();
        FieldNavigator navigator = new FieldNavigator(paramType);
        StringWriter json = new StringWriter();
        final JsonWriter jsonWriter = new JsonWriter(json);
        jsonWriter.beginObject();
        ValueReceiver receiver = new ValueReceiver() {
          @SuppressWarnings({"unchecked", "rawtypes"})
          @Override
          public void put(String name, Type type, Object value) throws IOException {
            jsonWriter.name(name);
            if (type instanceof TypeVariable || type == Object.class) {
              // We can not use Gson to extract the value, so just use the specified value.
              jsonWriter.value((String)value);
            } else {
              TypeAdapter adapter = gson.getAdapter(TypeToken.get(type));
              adapter.write(jsonWriter, value);
            }
          }
        };
        for (Field f : navigator.getFields()) {
          extractUrlParam(f.getName(), f.getGenericType(), requestParams, receiver);
        }
        jsonWriter.endObject();
        jsonWriter.close();
        Object obj = gson.fromJson(json.toString(), paramType);
View Full Code Here

TOP

Related Classes of com.google.greaze.definition.internal.utils.FieldNavigator

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.