List of usage examples for com.google.common.collect ImmutableMap builder
public static <K, V> Builder<K, V> builder()
From source file:org.semanticweb.elk.reasoner.config.EvictorBuilder.java
private static void put(final ImmutableMap.Builder<String, Class<?>> builder, final Class<?> value) {
builder.put(value.getSimpleName(), value);
}
From source file:com.tozny.mobiledemo.SessionDAO.java
public void insertSession(String userId, Session session) { sessionMap = new ImmutableMap.Builder<String, Session>().putAll(sessionMap).put(userId, session).build(); }
From source file:edu.cmu.lti.oaqa.baseqa.learning_base.Scorer.java
static void generateSummaryDistanceFeatures(double[] distances, ImmutableMap.Builder<String, Double> builder, double infinity, double smoothing, String keyword, String... operators) { // double[] avgPrecedingNegdistances = Arrays.stream(distances) // .map(distance -> distance - infinity).toArray(); // builder.putAll(generateSummaryFeatures(avgPrecedingNegdistances, keyword + "-negdistance", // operators)); double[] avgPrecedingProximities = Arrays.stream(distances).map(distance -> 1.0 / (smoothing + distance)) .toArray();//from w w w. j a va2s. c o m builder.putAll(generateSummaryFeatures(avgPrecedingProximities, keyword + "-proximity", operators)); }
From source file:controllers.Api.java
/** * @param id The resource ID//w w w . j a v a 2 s .co m * @param q A general query string * @param name The resource name * @param author The resource author * @param subject The resource subject * @param set The resource set * @param format The result format * @param from The start index of the result set * @param size The size of the result set * @return Matching resources */ public static Result resource(final String id, final String q, final String name, // NOPMD final String author, final String subject, final String set, final String format, final int from, final int size) { Logger.debug(String.format( "GET /resource; id: '%s', q: '%s', name: '%s', author: '%s', subject: '%s', format: '%s'", id, q, name, author, subject, format)); final Index index = Index.LOBID_RESOURCES; final Map.Entry<Parameter, String> parameter = Parameter .select(new ImmutableMap.Builder<Parameter, String>() /*@formatter:off*/ .put(Parameter.ID, id).put(Parameter.Q, q).put(Parameter.NAME, name) .put(Parameter.AUTHOR, author).put(Parameter.SUBJECT, subject).put(Parameter.SET, set) .build());/*@formatter:on*/ return Application.search(index, parameter.getKey(), parameter.getValue(), format, from, size); }
From source file:com.github.errantlinguist.latticevisualiser.StatePaintTransformer.java
/** * //from w ww.j a v a2 s . co m * @return A map of {@link StateType StateTypes} to {@link Color Colors} for * deriving the colour used to draw the vertex representing a state. */ static final ImmutableMap<StateType, Color> makeColorMap() { final ImmutableMap.Builder<StateType, Color> builder = ImmutableMap.builder(); builder.put(StateType.INITIAL, Color.CYAN); builder.put(StateType.FINAL, Color.MAGENTA); builder.put(StateType.GOAL, Color.RED); builder.put(StateType.INTERMEDIATE, Color.GREEN); return builder.build(); }
From source file:com.google.api.codegen.common.GeneratedResult.java
/** * Converts a map of results (body plus properties) to a map of bodies (stripping properties). * * @param results results map to convert * @param <T> class which represents result body *//*from ww w .j av a 2 s.c o m*/ public static <T> Map<String, T> extractBodies(Map<String, GeneratedResult<T>> results) { ImmutableMap.Builder<String, T> extractedResults = ImmutableMap.builder(); for (Map.Entry<String, GeneratedResult<T>> entry : results.entrySet()) { extractedResults.put(entry.getKey(), Objects.requireNonNull(entry.getValue().getBody())); } return extractedResults.build(); }
From source file:de.ii.xtraplatform.feature.provider.wfs.FeatureProviderRegisterWfs.java
@Override public Map<Class<?>, String> getMapping() { return new ImmutableMap.Builder<Class<?>, String>() .put(FeatureProviderDataWfs.class, FeatureProviderWfs.PROVIDER_TYPE).build(); }
From source file:io.prestosql.plugin.atop.LocalAtopQueryRunner.java
public static LocalQueryRunner createQueryRunner(Map<String, String> catalogProperties, Class<? extends AtopFactory> factoryClass) { Session session = testSessionBuilder().setCatalog("atop").setSchema("default") .setTimeZoneKey(TimeZoneKey.getTimeZoneKey(TimeZone.getDefault().getID())).build(); LocalQueryRunner queryRunner = new LocalQueryRunner(session); try {//w w w . j av a 2s. c om AtopConnectorFactory connectorFactory = new AtopConnectorFactory(factoryClass, LocalAtopQueryRunner.class.getClassLoader()); ImmutableMap.Builder<String, String> properties = ImmutableMap.<String, String>builder() .putAll(catalogProperties).put("atop.max-history-days", "1"); queryRunner.createCatalog("atop", connectorFactory, properties.build()); return queryRunner; } catch (Exception e) { closeAllSuppress(e, queryRunner); throw e; } }
From source file:de.ii.xtraplatform.feature.provider.pgis.FeatureProviderRegisterPgis.java
@Override public Map<Class<?>, String> getMapping() { return new ImmutableMap.Builder<Class<?>, String>() .put(FeatureProviderDataPgis.class, FeatureProviderPgis.PROVIDER_TYPE).build(); }
From source file:org.apache.beam.runners.direct.RootProviderRegistry.java
public static RootProviderRegistry defaultRegistry(EvaluationContext context) { ImmutableMap.Builder<String, RootInputProvider<?, ?, ?>> defaultProviders = ImmutableMap.builder(); defaultProviders.put(PTransformTranslation.READ_TRANSFORM_URN, ReadEvaluatorFactory.inputProvider(context)) .put(DIRECT_TEST_STREAM_URN, new TestStreamEvaluatorFactory.InputProvider(context)) .put(FLATTEN_TRANSFORM_URN, new EmptyInputProvider()); return new RootProviderRegistry(defaultProviders.build()); }