List of usage examples for java.util Collections emptyMap
@SuppressWarnings("unchecked") public static final <K, V> Map<K, V> emptyMap()
From source file:de.tntinteractive.portalsammler.engine.MapReaderTest.java
@Test public void testReadEmptyMap() throws Exception { final String input = "test123\n" + "."; final MapReader r = createReader(input); final Pair<String, Map<String, String>> p = r.readNext(); assertEquals("test123", p.getLeft()); assertEquals(Collections.emptyMap(), p.getRight()); assertNull(r.readNext());/*from w w w .j av a 2s . c o m*/ }
From source file:com.ikanow.aleph2.logging.utils.Log4JUtils.java
public static String getLog4JMessage(final JsonNode logObject, final Level level, final StackTraceElement stack, final String date_field, final Map<String, Object> map, final String hostname) { StringBuilder sb = new StringBuilder(); final String c = stack.getClassName().substring(stack.getClassName().lastIndexOf(".") + 1); final String l = Integer.toString(stack.getLineNumber()); final String thread = Thread.currentThread().getName().isEmpty() ? Long.toString(Thread.currentThread().getId()) : Thread.currentThread().getName(); sb.append(String.format(message_format, date_format.format(new Date(logObject.get(date_field).asLong())), thread, level.name(), c, l, logObject.get("message").asText())); sb.append(String.format(field_format, "bucket", logObject.get("bucket").asText())); sb.append(String.format(field_format, "hostname", hostname)); sb.append(String.format(field_format, "subsystem", logObject.get("subsystem").asText())); sb.append(String.format(field_format, "command", logObject.get("command").asText())); Optional.ofNullable(map).orElse(Collections.emptyMap()).entrySet().stream() .forEach(e -> sb.append(String.format(field_format, e.getKey(), e.getValue()))); return sb.toString(); }
From source file:com.orange.ngsi2.model.Attribute.java
public Map<String, Metadata> getMetadata() { if (metadata == null) { return Collections.emptyMap(); } return metadata; }
From source file:com.pinterest.deployservice.handler.DataHandler.java
public Map<String, String> getMapById(String id) throws Exception { if (StringUtils.isEmpty(id)) { return Collections.emptyMap(); }/* w w w . j a va2 s . co m*/ return CommonUtils.decodeData(dataDAO.getById(id).getData()); }
From source file:de.msquadrat.blobwizard.ServerConfiguration.java
public Map<String, Store> getStores() { if (stores == null) { return Collections.emptyMap(); }/*w ww.ja v a2 s .c o m*/ return Collections.unmodifiableMap(stores); }
From source file:org.elasticsearch.upgrades.TokenBackwardsCompatibilityIT.java
public void testGeneratingTokenInOldCluster() throws Exception { assumeTrue("this test should only run against the old cluster", clusterType == CLUSTER_TYPE.OLD); final StringEntity tokenPostBody = new StringEntity("{\n" + " \"username\": \"test_user\",\n" + " \"password\": \"x-pack-test-password\",\n" + " \"grant_type\": \"password\"\n" + "}", ContentType.APPLICATION_JSON); Response response = client().performRequest("POST", "_xpack/security/oauth2/token", Collections.emptyMap(), tokenPostBody);/* www .ja va2s . c o m*/ assertOK(response); Map<String, Object> responseMap = entityAsMap(response); String token = (String) responseMap.get("access_token"); assertNotNull(token); assertTokenWorks(token); StringEntity oldClusterToken = new StringEntity("{\n" + " \"token\": \"" + token + "\"\n" + "}", ContentType.APPLICATION_JSON); Response indexResponse = client().performRequest("PUT", "token_backwards_compatibility_it/doc/old_cluster_token1", Collections.emptyMap(), oldClusterToken); assertOK(indexResponse); response = client().performRequest("POST", "_xpack/security/oauth2/token", Collections.emptyMap(), tokenPostBody); assertOK(response); responseMap = entityAsMap(response); token = (String) responseMap.get("access_token"); assertNotNull(token); assertTokenWorks(token); oldClusterToken = new StringEntity("{\n" + " \"token\": \"" + token + "\"\n" + "}", ContentType.APPLICATION_JSON); indexResponse = client().performRequest("PUT", "token_backwards_compatibility_it/doc/old_cluster_token2", Collections.emptyMap(), oldClusterToken); assertOK(indexResponse); }
From source file:org.craftercms.core.xml.mergers.impl.DescriptorMergerImpl.java
public DescriptorMergerImpl() { initialMergeCueParams = Collections.emptyMap(); }
From source file:org.elasticsearch.rest.action.main.RestMainActionIT.java
public void testHeadRequest() throws IOException { try (Response response = getRestClient().performRequest("HEAD", "/", Collections.emptyMap(), null)) { assertThat(response.getStatusLine().getStatusCode(), equalTo(200)); assertNull(response.getEntity()); }/*w w w . j ava2 s. c o m*/ }
From source file:ch.cyberduck.core.Cache.java
public Cache(int size) { if (size == Integer.MAX_VALUE) { // Unlimited impl = Collections.synchronizedMap(new LinkedHashMap<T, AttributedList<T>>()); reverse = Collections.synchronizedMap(new LinkedHashMap<CacheReference, T>()); } else if (size == 0) { impl = Collections.emptyMap(); reverse = Collections.emptyMap(); } else {//from www.j av a 2 s. c o m // Will inflate to the given size impl = Collections.synchronizedMap(new LRUMap<T, AttributedList<T>>(size)); reverse = Collections.synchronizedMap(new LinkedHashMap<CacheReference, T>()); } }
From source file:cop.raml.utils.javadoc.MethodJavaDoc.java
@NotNull private static Map<String, TagParam> getParams(List<String> doc) { if (CollectionUtils.isEmpty(doc)) return Collections.emptyMap(); Map<String, TagParam> params = new LinkedMap<>(); String paramName = null;/* w w w .j av a 2 s.c om*/ StringBuilder buf = null; Matcher matcher; for (String line : doc) { line = line.trim(); if ((matcher = JavaDocTag.PARAM.getPattern().matcher(line)).find()) { if (paramName != null) addParameter(paramName, buf, params); paramName = matcher.group("name"); buf = new StringBuilder(StringUtils.defaultString(matcher.group("text"), "")); } else if (paramName != null) { if (TAG.matcher(line).find()) { addParameter(paramName, buf, params); paramName = null; } else if (buf.length() > 0) buf.append('\n').append(line); else buf.append(line); } } if (paramName != null) addParameter(paramName, buf, params); return params.isEmpty() ? Collections.emptyMap() : Collections.unmodifiableMap(params); }