Tabnine Logo
Collections.emptyMap
Code IndexAdd Tabnine to your IDE (free)

How to use
emptyMap
method
in
java.util.Collections

Best Java code snippets using java.util.Collections.emptyMap (Showing top 20 results out of 56,475)

Refine searchRefine arrow

  • Map.put
  • Map.get
  • Map.Entry.getKey
  • Map.Entry.getValue
  • Map.entrySet
  • Test.<init>
  • Collections.unmodifiableMap
  • Assert.assertEquals
origin: square/okhttp

/** Returns an immutable copy of {@code map}. */
public static <K, V> Map<K, V> immutableMap(Map<K, V> map) {
 return map.isEmpty()
   ? Collections.emptyMap()
   : Collections.unmodifiableMap(new LinkedHashMap<>(map));
}
origin: skylot/jadx

  public static Map<String, String> newConstStringMap(String... parameters) {
    int len = parameters.length;
    if (len == 0) {
      return Collections.emptyMap();
    }
    Map<String, String> result = new HashMap<>(len / 2);
    for (int i = 0; i < len; i += 2) {
      result.put(parameters[i], parameters[i + 1]);
    }
    return Collections.unmodifiableMap(result);
  }
}
origin: spring-projects/spring-framework

@Override
@SuppressWarnings("unchecked")
protected Object resolveNamedValue(String name, MethodParameter parameter, ServerWebExchange exchange) {
  String attributeName = HandlerMapping.URI_TEMPLATE_VARIABLES_ATTRIBUTE;
  return exchange.getAttributeOrDefault(attributeName, Collections.emptyMap()).get(name);
}
origin: Graylog2/graylog2-server

  private Map<String, String> prefixElements(final String prefix, final Map<String, String> elements) {
    if (elements == null || elements.isEmpty()) {
      return Collections.emptyMap();
    }

    final Map<String, String> prefixedMap = new HashMap<>(elements.size());
    for (Map.Entry<String, String> entry : elements.entrySet()) {
      prefixedMap.put(prefix.trim() + "_" + entry.getKey(), entry.getValue());
    }

    return prefixedMap;
  }
}
origin: mpusher/mpush

@Override
public <T> Map<String, T> hgetAll(String key, Class<T> clazz) {
  Map<String, Object> m = (Map) cache.get(key);
  if (m == null || m.isEmpty()) return Collections.emptyMap();
  Map<String, T> result = new HashMap<>();
  for (Map.Entry<String, Object> o : m.entrySet()) {
    result.put(o.getKey(), Jsons.fromJson(String.valueOf(o.getValue()), clazz));
  }
  return result;
}
origin: apache/kafka

@Test
public void testSaslLoginRefreshDefaults() {
  Map<String, Object> vals = new ConfigDef().withClientSaslSupport().parse(Collections.emptyMap());
  assertEquals(SaslConfigs.DEFAULT_LOGIN_REFRESH_WINDOW_FACTOR,
      vals.get(SaslConfigs.SASL_LOGIN_REFRESH_WINDOW_FACTOR));
  assertEquals(SaslConfigs.DEFAULT_LOGIN_REFRESH_WINDOW_JITTER,
      vals.get(SaslConfigs.SASL_LOGIN_REFRESH_WINDOW_JITTER));
  assertEquals(SaslConfigs.DEFAULT_LOGIN_REFRESH_MIN_PERIOD_SECONDS,
      vals.get(SaslConfigs.SASL_LOGIN_REFRESH_MIN_PERIOD_SECONDS));
  assertEquals(SaslConfigs.DEFAULT_LOGIN_REFRESH_BUFFER_SECONDS,
      vals.get(SaslConfigs.SASL_LOGIN_REFRESH_BUFFER_SECONDS));
}
origin: Activiti/Activiti

public Map<String, Object> getTransientVariablesLocal() {
 if (transientVariabes != null) {
  Map<String, Object> variables = new HashMap<String, Object>();
  for (String variableName : transientVariabes.keySet()) {
   variables.put(variableName, transientVariabes.get(variableName).getValue());
  }
  return variables;
 } else {
  return Collections.emptyMap();
 }
}

origin: spring-projects/spring-framework

@Test
@SuppressWarnings("unchecked")
public void resolveArgumentNoUriVars() throws Exception {
  Map<String, String> map = (Map<String, String>) resolver.resolveArgument(paramMap, mavContainer, webRequest, null);
  assertEquals(Collections.emptyMap(), map);
}
origin: spring-projects/spring-security

@Test
public void convertWhenIssuerIsOfTypeURLThenConvertsToString() throws Exception {
  MappedJwtClaimSetConverter converter = MappedJwtClaimSetConverter
      .withDefaults(Collections.emptyMap());
  Map<String, Object> issuer = Collections.singletonMap(JwtClaimNames.ISS, new URL("https://issuer"));
  Map<String, Object> target = converter.convert(issuer);
  assertThat(target.get(JwtClaimNames.ISS)).isEqualTo("https://issuer");
}
origin: Netflix/eureka

  private static Map<String, String> headersOf(Response response) {
    MultivaluedMap<String, String> jerseyHeaders = response.getStringHeaders();
    if (jerseyHeaders == null || jerseyHeaders.isEmpty()) {
      return Collections.emptyMap();
    }
    Map<String, String> headers = new HashMap<>();
    for (Entry<String, List<String>> entry : jerseyHeaders.entrySet()) {
      if (!entry.getValue().isEmpty()) {
        headers.put(entry.getKey(), entry.getValue().get(0));
      }
    }
    return headers;
  }
}
origin: SonarSource/sonarqube

@Override
public ActiveRule find(RuleKey ruleKey) {
 return activeRulesByRepositoryAndKey.getOrDefault(ruleKey.repository(), Collections.emptyMap())
  .get(ruleKey.rule());
}
origin: apache/storm

/**
 * Get a map of version to worker log writer from the conf Config.SUPERVISOR_WORKER_VERSION_LOGWRITER_MAP
 *
 * @param conf what to read it out of
 * @return the map
 */
public static NavigableMap<SimpleVersion, String> getConfiguredWorkerLogWriterVersions(Map<String, Object> conf) {
  TreeMap<SimpleVersion, String> ret = new TreeMap<>();
  Map<String, String> fromConf =
    (Map<String, String>) conf.getOrDefault(Config.SUPERVISOR_WORKER_VERSION_LOGWRITER_MAP, Collections.emptyMap());
  for (Map.Entry<String, String> entry : fromConf.entrySet()) {
    ret.put(new SimpleVersion(entry.getKey()), entry.getValue());
  }
  ret.put(VersionInfo.OUR_VERSION, "org.apache.storm.LogWriter");
  return ret;
}
origin: spring-projects/spring-framework

@Test(expected = InvalidDataAccessApiUsageException.class)
public void buildValueArrayWithMissingParameterValue() {
  String sql = "select count(0) from foo where id = :id";
  NamedParameterUtils.buildValueArray(sql, Collections.<String, Object>emptyMap());
}
origin: square/okhttp

@Override public List<Cookie> loadForRequest(HttpUrl url) {
 // The RI passes all headers. We don't have 'em, so we don't pass 'em!
 Map<String, List<String>> headers = Collections.emptyMap();
 Map<String, List<String>> cookieHeaders;
 try {
  cookieHeaders = cookieHandler.get(url.uri(), headers);
 } catch (IOException e) {
  Platform.get().log(WARN, "Loading cookies failed for " + url.resolve("/..."), e);
  return Collections.emptyList();
 }
 List<Cookie> cookies = null;
 for (Map.Entry<String, List<String>> entry : cookieHeaders.entrySet()) {
  String key = entry.getKey();
  if (("Cookie".equalsIgnoreCase(key) || "Cookie2".equalsIgnoreCase(key))
    && !entry.getValue().isEmpty()) {
   for (String header : entry.getValue()) {
    if (cookies == null) cookies = new ArrayList<>();
    cookies.addAll(decodeHeaderAsJavaNetCookies(url, header));
   }
  }
 }
 return cookies != null
   ? Collections.unmodifiableList(cookies)
   : Collections.emptyList();
}
origin: spring-projects/spring-framework

/**
 * Create a WebSocketExtension with the given name and parameters.
 * @param name the name of the extension
 * @param parameters the parameters
 */
public WebSocketExtension(String name, @Nullable Map<String, String> parameters) {
  Assert.hasLength(name, "Extension name must not be empty");
  this.name = name;
  if (!CollectionUtils.isEmpty(parameters)) {
    Map<String, String> map = new LinkedCaseInsensitiveMap<>(parameters.size(), Locale.ENGLISH);
    map.putAll(parameters);
    this.parameters = Collections.unmodifiableMap(map);
  }
  else {
    this.parameters = Collections.emptyMap();
  }
}
origin: skylot/jadx

public Map<CodePosition, JavaNode> getUsageMap() {
  Map<CodePosition, Object> map = getCodeAnnotations();
  if (map.isEmpty() || decompiler == null) {
    return Collections.emptyMap();
  }
  Map<CodePosition, JavaNode> resultMap = new HashMap<>(map.size());
  for (Map.Entry<CodePosition, Object> entry : map.entrySet()) {
    CodePosition codePosition = entry.getKey();
    Object obj = entry.getValue();
    if (obj instanceof LineAttrNode) {
      JavaNode node = convertNode(obj);
      if (node != null) {
        resultMap.put(codePosition, node);
      }
    }
  }
  return resultMap;
}
origin: prestodb/presto

  @Override
  public Optional<Map<DecoderColumnHandle, FieldValueProvider>> decodeRow(byte[] data, Map<String, String> dataMap)
  {
    if (dataMap == null) {
      return Optional.of(emptyMap());
    }

    Map<DecoderColumnHandle, FieldValueProvider> decodedRow = new HashMap<>();
    for (Map.Entry<DecoderColumnHandle, RedisFieldDecoder<String>> entry : fieldDecoders.entrySet()) {
      DecoderColumnHandle columnHandle = entry.getKey();

      String mapping = columnHandle.getMapping();
      checkState(mapping != null, "No mapping for column handle %s!", columnHandle);

      String valueField = dataMap.get(mapping);

      RedisFieldDecoder<String> decoder = entry.getValue();
      decodedRow.put(columnHandle, decoder.decode(valueField, columnHandle));
    }
    return Optional.of(decodedRow);
  }
}
origin: apache/storm

@Test
public void getNimbusAutoCredPluginTest() {
  Map<String, Object> map = new HashMap<>();
  map.put(Config.NIMBUS_AUTO_CRED_PLUGINS,
      Arrays.asList(new String[]{ "org.apache.storm.security.auth.AuthUtilsTestMock" }));
  Assert.assertTrue(ClientAuthUtils.getNimbusAutoCredPlugins(Collections.emptyMap()).isEmpty());
  Assert.assertEquals(ClientAuthUtils.getNimbusAutoCredPlugins(map).size(), 1);
}
origin: spring-projects/spring-framework

  return Collections.emptyMap();
Map<String, List<String>> map = attributeAliasesCache.get(annotationType);
if (map != null) {
  return map;
  List<String> aliasNames = getAttributeAliasNames(attribute);
  if (!aliasNames.isEmpty()) {
    map.put(attribute.getName(), aliasNames);
attributeAliasesCache.put(annotationType, map);
return map;
origin: redisson/redisson

/**
 * {@inheritDoc}
 */
public Generic get(int index) {
  // Avoid resolution of interface bound type unless a type annotation can be possibly resolved.
  Map<String, List<AnnotationToken>> annotationTokens = !this.annotationTokens.containsKey(index) && !this.annotationTokens.containsKey(index + 1)
      ? Collections.<String, List<AnnotationToken>>emptyMap()
      : this.annotationTokens.get(index + (boundTypeTokens.get(0).isPrimaryBound(typePool) ? 0 : 1));
  return boundTypeTokens.get(index).toGenericType(typePool,
      typeVariableSource,
      EMPTY_TYPE_PATH,
      annotationTokens == null
          ? Collections.<String, List<AnnotationToken>>emptyMap()
          : annotationTokens);
}
java.utilCollectionsemptyMap

Javadoc

Returns a type-safe empty, immutable Map.

Popular methods of Collections

  • emptyList
    Returns the empty list (immutable). This list is serializable.This example illustrates the type-safe
  • sort
  • singletonList
    Returns an immutable list containing only the specified object. The returned list is serializable.
  • unmodifiableList
    Returns an unmodifiable view of the specified list. This method allows modules to provide users with
  • emptySet
    Returns the empty set (immutable). This set is serializable. Unlike the like-named field, this metho
  • unmodifiableMap
    Returns an unmodifiable view of the specified map. This method allows modules to provide users with
  • singleton
    Returns an immutable set containing only the specified object. The returned set is serializable.
  • unmodifiableSet
    Returns an unmodifiable view of the specified set. This method allows modules to provide users with
  • singletonMap
    Returns an immutable map, mapping only the specified key to the specified value. The returned map is
  • addAll
    Adds all of the specified elements to the specified collection. Elements to be added may be specifie
  • reverse
    Reverses the order of the elements in the specified list. This method runs in linear time.
  • unmodifiableCollection
    Returns an unmodifiable view of the specified collection. This method allows modules to provide user
  • reverse,
  • unmodifiableCollection,
  • shuffle,
  • enumeration,
  • list,
  • synchronizedMap,
  • synchronizedList,
  • reverseOrder,
  • emptyIterator

Popular in Java

  • Parsing JSON documents to java classes using gson
  • onCreateOptionsMenu (Activity)
  • runOnUiThread (Activity)
  • orElseThrow (Optional)
    Return the contained value, if present, otherwise throw an exception to be created by the provided s
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • TimeZone (java.util)
    TimeZone represents a time zone offset, and also figures out daylight savings. Typically, you get a
  • ThreadPoolExecutor (java.util.concurrent)
    An ExecutorService that executes each submitted task using one of possibly several pooled threads, n
  • Filter (javax.servlet)
    A filter is an object that performs filtering tasks on either the request to a resource (a servlet o
  • Runner (org.openjdk.jmh.runner)
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now