List of usage examples for com.google.common.reflect TypeToken TypeToken
protected TypeToken()
From source file:com.kurtraschke.nyctrtproxy.services.TripUpdateProcessor.java
@Inject(optional = true) public void setRouteBlacklistByFeed(@Named("NYCT.routeBlacklistByFeed") String json) { Type type = new TypeToken<Map<Integer, Set<String>>>() { }.getType();/*from w w w. j av a 2 s. co m*/ _routeBlacklistByFeed = new Gson().fromJson(json, type); }
From source file:fixtures.bodynumber.NumberImpl.java
private ServiceResponse<Double> getNullDelegate(Response<ResponseBody> response, Retrofit retrofit) throws ErrorException, IOException { return new ServiceResponseBuilder<Double, ErrorException>().register(200, new TypeToken<Double>() { }.getType()).registerError(ErrorException.class).build(response, retrofit); }
From source file:co.cask.cdap.client.StreamViewClient.java
/** * Lists all views associated with a stream. * * @return the list of views associated with a stream *//* w w w. ja v a2s. c om*/ public List<String> list(Id.Stream stream) throws IOException, UnauthenticatedException { URL url = config.resolveNamespacedURLV3(stream.getNamespace(), String.format("streams/%s/views", stream.getId())); HttpResponse response = restClient.execute(HttpMethod.GET, url, config.getAccessToken()); return ObjectResponse.fromJsonBody(response, new TypeToken<List<String>>() { }).getResponseObject(); }
From source file:org.apache.gobblin.hive.HiveRegistrationUnit.java
@SuppressWarnings({ "serial" }) protected void populateStorageFields(State state) { this.location = populateField(state, HiveConstants.LOCATION, new TypeToken<String>() { });//from www . ja v a 2 s . c om this.inputFormat = populateField(state, HiveConstants.INPUT_FORMAT, new TypeToken<String>() { }); this.outputFormat = populateField(state, HiveConstants.OUTPUT_FORMAT, new TypeToken<String>() { }); this.isCompressed = populateField(state, HiveConstants.COMPRESSED, new TypeToken<Boolean>() { }); this.numBuckets = populateField(state, HiveConstants.NUM_BUCKETS, new TypeToken<Integer>() { }); this.bucketColumns = populateField(state, HiveConstants.BUCKET_COLUMNS, new TypeToken<List<String>>() { }); this.isStoredAsSubDirs = populateField(state, HiveConstants.STORED_AS_SUB_DIRS, new TypeToken<Boolean>() { }); }
From source file:org.eclipse.gef4.mvc.operations.ChangeFocusOperation.java
/** * Returns the {@link FocusModel} adapted to the viewer. * * @return The {@link FocusModel} adapter. *//*from w w w. ja va 2 s .c o m*/ @SuppressWarnings("serial") protected FocusModel<VR> getFocusModel() { FocusModel<VR> focusModel = viewer.getAdapter(new TypeToken<FocusModel<VR>>() { }.where(new TypeParameter<VR>() { }, Types.<VR>argumentOf(viewer.getClass()))); return focusModel; }
From source file:org.eclipse.gef4.mvc.fx.parts.FXHoverFeedbackPart.java
/** * Returns the {@link Effect} that is provided by the * <code>Provider<Effect></code> of this part's first anchorage. * * @return The {@link Effect} that is provided by the * <code>Provider<Effect></code> of this part's first * anchorage.// www. j a va 2s . co m */ @SuppressWarnings("serial") public Effect getHoverFeedbackEffect() { Provider<? extends Effect> effectProvider = null; if (!getAnchorages().isEmpty()) { IVisualPart<Node, ? extends Node> host = getAnchorages().keys().iterator().next(); effectProvider = host.getAdapter(AdapterKey.get(new TypeToken<Provider<? extends Effect>>() { }, EFFECT_PROVIDER)); } if (effectProvider == null) { DropShadow effect = new DropShadow(); effect.setRadius(3); return effect; } return effectProvider.get(); }
From source file:richtercloud.reflection.form.builder.fieldhandler.factory.MappingFieldHandlerFactory.java
@SuppressWarnings("serial") public static Type createBooleanTypeToken() { return new TypeToken<Boolean>() { }.getType();//from w w w. ja va2s. c om }
From source file:org.apache.twill.internal.json.TwillRuntimeSpecificationCodec.java
@Override public TwillRuntimeSpecification deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context) throws JsonParseException { JsonObject jsonObj = json.getAsJsonObject(); TwillSpecification twillSpecification = context.deserialize(jsonObj.get(TWILL_SPEC), new TypeToken<TwillSpecification>() { }.getType());//from www. java 2 s . com Map<String, Map<String, String>> logLevels = context.deserialize(jsonObj.get(LOG_LEVELS), MAP_STRING_MAP_STRING_STRING_TYPE); Map<String, Integer> maxRetries = context.deserialize(jsonObj.get(MAX_RETRIES), new TypeToken<Map<String, Integer>>() { }.getType()); Map<String, String> config = context.deserialize(jsonObj.get(CONFIG), new TypeToken<Map<String, String>>() { }.getType()); Map<String, Map<String, String>> runnableConfigs = context.deserialize(jsonObj.get(RUNNABLE_CONFIGS), MAP_STRING_MAP_STRING_STRING_TYPE); return new TwillRuntimeSpecification(twillSpecification, jsonObj.get(FS_USER).getAsString(), URI.create(jsonObj.get(TWILL_APP_DIR).getAsString()), jsonObj.get(ZK_CONNECT_STR).getAsString(), RunIds.fromString(jsonObj.get(TWILL_RUNID).getAsString()), jsonObj.get(TWILL_APP_NAME).getAsString(), jsonObj.has(RM_SCHEDULER_ADDR) ? jsonObj.get(RM_SCHEDULER_ADDR).getAsString() : null, logLevels, maxRetries, config, runnableConfigs); }
From source file:org.openqa.selenium.docker.Docker.java
public List<Image> listImages() { LOG.fine("Listing images"); HttpResponse response = client.apply(new HttpRequest(GET, "/images/json")); List<ImageSummary> images = JSON.toType(response.getContentString(), new TypeToken<List<ImageSummary>>() { }.getType());// ww w. j av a 2 s.c om return images.stream().map(Image::new).collect(toImmutableList()); }
From source file:com.qmetry.qaf.automation.util.JSONUtil.java
public static Object[][] getJsonArrayOfMaps(String file) { try {/* w ww . ja v a2 s. co m*/ Gson gson = new Gson(); final Type DATASET_TYPE = new TypeToken<List<Map<String, Object>>>() { private static final long serialVersionUID = 4426388930719377223L; }.getType(); List<Map<String, Object>[]> mapData; if (file.startsWith("[")) mapData = gson.fromJson(file, DATASET_TYPE); else { String jsonStr = FileUtil.readFileToString(new File(file)); mapData = gson.fromJson(jsonStr, DATASET_TYPE); } Object[][] objecttoreturn = new Object[mapData.size()][1]; for (int i = 0; i < mapData.size(); i++) { objecttoreturn[i][0] = mapData.get(i); } return objecttoreturn;// mapData.toArray(new Object[][]{}); } catch (Throwable e) { throw new AutomationError(e); } }