List of usage examples for com.google.common.collect ImmutableMap of
public static <K, V> ImmutableMap<K, V> of(K k1, V v1, K k2, V v2, K k3, V v3, K k4, V v4, K k5, V v5)
From source file:com.facebook.buck.skylark.function.HostInfo.java
@VisibleForTesting static SkylarkInfo createHostInfoStruct(Supplier<Platform> platformSupplier, Supplier<Architecture> architectureSupplier) { Platform hostPlatform = platformSupplier.get(); Architecture hostArchitecture = architectureSupplier.get(); ImmutableMap<String, Object> os = ImmutableMap.of("is_linux", hostPlatform == Platform.LINUX, "is_macos", hostPlatform == Platform.MACOS, "is_windows", hostPlatform == Platform.WINDOWS, "is_freebsd", hostPlatform == Platform.FREEBSD, "is_unknown", hostPlatform == Platform.UNKNOWN); ImmutableMap<String, Object> arch = ImmutableMap.<String, Object>builder() .put("is_aarch64", hostArchitecture == Architecture.AARCH64) .put("is_arm", hostArchitecture == Architecture.ARM) .put("is_armeb", hostArchitecture == Architecture.ARMEB) .put("is_i386", hostArchitecture == Architecture.I386) .put("is_mips", hostArchitecture == Architecture.MIPS) .put("is_mips64", hostArchitecture == Architecture.MIPS64) .put("is_mipsel", hostArchitecture == Architecture.MIPSEL) .put("is_mipsel64", hostArchitecture == Architecture.MIPSEL64) .put("is_powerpc", hostArchitecture == Architecture.POWERPC) .put("is_ppc64", hostArchitecture == Architecture.PPC64) .put("is_unknown", hostArchitecture == Architecture.UNKNOWN) .put("is_x86_64", hostArchitecture == Architecture.X86_64).build(); return StructProvider.STRUCT.create( ImmutableMap.of("os", StructProvider.STRUCT.create(os, "no such property on os struct: '%s'"), "arch", StructProvider.STRUCT.create(arch, "no such property on arch struct: '%s'")), "no such property on host_info struct: '%s'"); }
From source file:io.prestosql.plugin.redis.util.RedisTestUtils.java
public static void installRedisPlugin(EmbeddedRedis embeddedRedis, QueryRunner queryRunner, Map<SchemaTableName, RedisTableDescription> tableDescriptions) { RedisPlugin redisPlugin = new RedisPlugin(); redisPlugin.setTableDescriptionSupplier(() -> tableDescriptions); queryRunner.installPlugin(redisPlugin); Map<String, String> redisConfig = ImmutableMap.of("redis.nodes", embeddedRedis.getConnectString() + ":" + embeddedRedis.getPort(), "redis.table-names", Joiner.on(",").join(tableDescriptions.keySet()), "redis.default-schema", "default", "redis.hide-internal-columns", "true", "redis.key-prefix-schema-table", "true"); queryRunner.createCatalog("redis", "redis", redisConfig); }
From source file:com.facebook.presto.redis.util.RedisTestUtils.java
public static void installRedisPlugin(EmbeddedRedis embeddedRedis, QueryRunner queryRunner, Map<SchemaTableName, RedisTableDescription> tableDescriptions) { RedisPlugin redisPlugin = new RedisPlugin(); redisPlugin.setTableDescriptionSupplier(Suppliers.ofInstance(tableDescriptions)); queryRunner.installPlugin(redisPlugin); Map<String, String> redisConfig = ImmutableMap.of("redis.nodes", embeddedRedis.getConnectString() + ":" + embeddedRedis.getPort(), "redis.table-names", Joiner.on(",").join(tableDescriptions.keySet()), "redis.default-schema", "default", "redis.hide-internal-columns", "true", "redis.key-prefix-schema-table", "true"); queryRunner.createCatalog("redis", "redis", redisConfig); }
From source file:org.graylog2.indexer.IndexMapping2.java
@Override protected Map<String, Map<String, Object>> fieldProperties(String analyzer) { return ImmutableMap.of("message", analyzedString(analyzer), "full_message", analyzedString(analyzer), // http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html // http://www.elasticsearch.org/guide/reference/mapping/date-format.html "timestamp", typeTimeWithMillis(), // to support wildcard searches in source we need to lowercase the content (wildcard search lowercases search term) "source", analyzedString("analyzer_keyword"), "streams", notAnalyzedString()); }
From source file:org.graylog2.indexer.IndexMapping5.java
@Override protected Map<String, Map<String, Object>> fieldProperties(String analyzer) { return ImmutableMap.of("message", analyzedString(analyzer, false), "full_message", analyzedString(analyzer, false), // http://joda-time.sourceforge.net/api-release/org/joda/time/format/DateTimeFormat.html // http://www.elasticsearch.org/guide/reference/mapping/date-format.html "timestamp", typeTimeWithMillis(), // to support wildcard searches in source we need to lowercase the content (wildcard search lowercases search term) "source", analyzedString("analyzer_keyword", true), "streams", notAnalyzedString()); }
From source file:org.sonar.core.persistence.DatabaseCommands.java
public static DatabaseCommands forDialect(Dialect dialect) { DatabaseCommands command = ImmutableMap.of(org.sonar.core.persistence.dialect.H2.ID, H2, MsSql.ID, MSSQL, MySql.ID, MYSQL, Oracle.ID, ORACLE, PostgreSql.ID, POSTGRESQL).get(dialect.getId()); return Preconditions.checkNotNull(command, "Unknown database: " + dialect); }
From source file:org.openhab.binding.ekozefir.response.turninglistener.TurningResponseListenerCreator.java
/** * {@inheritDoc}/*from w ww .java 2 s .c o m*/ */ @Override public ResponseListener create(final String item, final EventPublisher publisher) { Objects.requireNonNull(item); Objects.requireNonNull(publisher); return new ResponseListener() { private final int byteNumberOfResponse = 3; private final Map<Integer, OnOffType> values = ImmutableMap.of(1, OnOffType.ON, 2, OnOffType.ON, 3, OnOffType.OFF, 4, OnOffType.OFF, 5, OnOffType.OFF); @Override @Subscribe public void listen(Response event) { Objects.requireNonNull(event); int value = event.convertByteOfNumberToInt(byteNumberOfResponse); if (!values.containsKey(value)) { throw new UnsupportedByteValueException(getClass(), value); } publisher.postUpdate(item, values.get(value)); } }; }
From source file:org.openhab.binding.ekozefir.response.statuslistener.StatusResponseListenerCreator.java
/** * {@inheritDoc}//from ww w . j av a 2s .c o m */ @Override public ResponseListener create(final String item, final EventPublisher publisher) { Objects.requireNonNull(item); Objects.requireNonNull(publisher); return new ResponseListener() { private final int byteNumberOfResponse = 3; private final Map<Integer, StringType> values = ImmutableMap.of(1, new StringType("STARTING"), 2, new StringType("WORK"), 3, new StringType("SHUTDOWN"), 4, new StringType("STANDBY"), 5, new StringType("ALERT")); @Subscribe @Override public void listen(Response event) { Objects.requireNonNull(event); int value = event.convertByteOfNumberToInt(byteNumberOfResponse); if (!values.containsKey(value)) { throw new UnsupportedByteValueException(getClass(), value); } publisher.postUpdate(item, values.get(value)); } }; }
From source file:org.openqa.selenium.remote.server.handler.Status.java
@Override public Response handle() { Response response = new Response(); response.setStatus(ErrorCodes.SUCCESS); response.setState(ErrorCodes.SUCCESS_STRING); BuildInfo buildInfo = new BuildInfo(); Object info = ImmutableMap.of("ready", true, "message", "Server is running", "build", ImmutableMap.of("version", buildInfo.getReleaseLabel(), "revision", buildInfo.getBuildRevision(), "time", buildInfo.getBuildTime()), "os", ImmutableMap.of("name", System.getProperty("os.name"), "arch", System.getProperty("os.arch"), "version", System.getProperty("os.version")), "java", ImmutableMap.of("version", System.getProperty("java.version"))); response.setValue(info);//from www.jav a 2 s. c o m return response; }