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

How to use
unmodifiableMap
method
in
java.util.Collections

Best Java code snippets using java.util.Collections.unmodifiableMap (Showing top 20 results out of 47,547)

Refine searchRefine arrow

  • Map.put
  • Map.Entry.getKey
  • Map.Entry.getValue
  • Map.entrySet
  • Collections.emptyMap
  • Map.get
origin: spring-projects/spring-framework

PathMatchInfo(Map<String, String> uriVars,
    @Nullable Map<String, MultiValueMap<String, String>> matrixVars) {
  this.uriVariables = Collections.unmodifiableMap(uriVars);
  this.matrixVariables = matrixVars != null ?
      Collections.unmodifiableMap(matrixVars) : Collections.emptyMap();
}
origin: stackoverflow.com

 public class Test {
  private static final Map<Integer, String> myMap;
  static {
    Map<Integer, String> aMap = ....;
    aMap.put(1, "one");
    aMap.put(2, "two");
    myMap = Collections.unmodifiableMap(aMap);
  }
}
origin: spring-projects/spring-framework

public Set<Map.Entry<String, Object>> entrySet() {
  return Collections.unmodifiableMap(this.headers).entrySet();
}
origin: stackoverflow.com

 Map<String, String> realMap = new HashMap<String, String>();
realMap.put("A", "B");

Map<String, String> unmodifiableMap = Collections.unmodifiableMap(realMap);

// This is not possible: It would throw an 
// UnsupportedOperationException
//unmodifiableMap.put("C", "D");

// This is still possible:
realMap.put("E", "F");

// The change in the "realMap" is now also visible
// in the "unmodifiableMap". So the unmodifiableMap
// has changed after it has been created.
unmodifiableMap.get("E"); // Will return "F".
origin: square/okhttp

public Challenge(String scheme, Map<String, String> authParams) {
 if (scheme == null) throw new NullPointerException("scheme == null");
 if (authParams == null) throw new NullPointerException("authParams == null");
 this.scheme = scheme;
 Map<String, String> newAuthParams = new LinkedHashMap<>();
 for (Entry<String, String> authParam : authParams.entrySet()) {
  String key = (authParam.getKey() == null) ? null : authParam.getKey().toLowerCase(US);
  newAuthParams.put(key, authParam.getValue());
 }
 this.authParams = unmodifiableMap(newAuthParams);
}
origin: wildfly/wildfly

@Override
public JsonWriterFactory createWriterFactory(Map<String, ?> config) {
  Map<String, Object> providerConfig;
  boolean prettyPrinting;
  BufferPool pool;
  if (config == null) {
    providerConfig = Collections.emptyMap();
    prettyPrinting = false;
    pool = bufferPool;
  } else {
    providerConfig = new HashMap<>();
    if (prettyPrinting=JsonProviderImpl.isPrettyPrintingEnabled(config)) {
      providerConfig.put(JsonGenerator.PRETTY_PRINTING, true);
    }
    pool = (BufferPool)config.get(BufferPool.class.getName());
    if (pool != null) {
      providerConfig.put(BufferPool.class.getName(), pool);
    } else {
      pool = bufferPool;
    }
    providerConfig = Collections.unmodifiableMap(providerConfig);
  }
  return new JsonWriterFactoryImpl(providerConfig, prettyPrinting, pool);
}
origin: primefaces/primefaces

@Override
public Map getParameterMap() {
  if (parameterMap == null) {
    Map<String, String[]> map = new LinkedHashMap<>();
    for (String formParam : formParams.keySet()) {
      map.put(formParam, formParams.get(formParam).toArray(new String[0]));
    }
    map.putAll(super.getParameterMap());
    parameterMap = Collections.unmodifiableMap(map);
  }
  return parameterMap;
}
origin: cloudfoundry/uaa

public static Map<String, Map<String, Object>> parseYaml(String sampleYaml) {
  YamlMapFactoryBean factory = new YamlMapFactoryBean();
  factory.setResolutionMethod(YamlProcessor.ResolutionMethod.OVERRIDE_AND_IGNORE);
  List<Resource> resources = new ArrayList<>();
  ByteArrayResource resource = new ByteArrayResource(sampleYaml.getBytes());
  resources.add(resource);
  factory.setResources(resources.toArray(new Resource[resources.size()]));
  Map<String, Object> tmpdata = factory.getObject();
  Map<String, Map<String, Object>> dataMap = new HashMap<>();
  for (Map.Entry<String, Object> entry : ((Map<String, Object>)tmpdata.get("providers")).entrySet()) {
    dataMap.put(entry.getKey(), (Map<String, Object>)entry.getValue());
  }
  return Collections.unmodifiableMap(dataMap);
}
origin: Alluxio/alluxio

@Override
public Map<String, Long> updateValues(Map<MetricsFilter, Set<Metric>> map) {
 Map<String, Long> updated = new HashMap<>();
 for (Metric metric : map.get(mFilter)) {
  Map<String, String> tags = metric.getTags();
  if (tags.containsKey(mTagName)) {
   String ufsName = MetricsSystem.getClusterMetricName(
     Metric.getMetricNameWithTags(mAggregationName, mTagName, tags.get(mTagName)));
   long value = updated.getOrDefault(ufsName, 0L);
   updated.put(ufsName, (long) (value + metric.getValue()));
  }
 }
 synchronized (this) {
  mAggregates = updated;
 }
 return Collections.unmodifiableMap(mAggregates);
}
origin: wildfly/wildfly

public Map<InjectionTarget, ResourceInjectionConfiguration> getResourceInjections(final String className) {
  Map<InjectionTarget, ResourceInjectionConfiguration> injections = resourceInjections.get(className);
  if (injections == null) {
    return Collections.emptyMap();
  } else {
    return Collections.unmodifiableMap(injections);
  }
}
origin: apache/ignite

  /**
   * @param statType Type of statistics which need to take.
   * @return All tracked statistics for given type.
   */
  public Map<IoStatisticsHolderKey, IoStatisticsHolder> statistics(IoStatisticsType statType){
    return Collections.unmodifiableMap(statByType.get(statType));
  }
}
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

/**
 * 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: google/ExoPlayer

/** Returns a map of metadata name, value pairs to be set. Values are copied.  */
public Map<String, Object> getEditedValues() {
 HashMap<String, Object> hashMap = new HashMap<>(editedValues);
 for (Entry<String, Object> entry : hashMap.entrySet()) {
  Object value = entry.getValue();
  if (value instanceof byte[]) {
   byte[] bytes = (byte[]) value;
   entry.setValue(Arrays.copyOf(bytes, bytes.length));
  }
 }
 return Collections.unmodifiableMap(hashMap);
}
origin: spring-projects/spring-framework

/**
 * Build a mapping of {@link TypeVariable#getName TypeVariable names} to
 * {@link Class concrete classes} for the specified {@link Class}.
 * Searches all super types, enclosing types and interfaces.
 * @see #resolveType(Type, Map)
 */
@SuppressWarnings("rawtypes")
public static Map<TypeVariable, Type> getTypeVariableMap(Class<?> clazz) {
  Map<TypeVariable, Type> typeVariableMap = typeVariableCache.get(clazz);
  if (typeVariableMap == null) {
    typeVariableMap = new HashMap<>();
    buildTypeVariableMap(ResolvableType.forClass(clazz), typeVariableMap);
    typeVariableCache.put(clazz, Collections.unmodifiableMap(typeVariableMap));
  }
  return typeVariableMap;
}
origin: square/leakcanary

private Map<String, Exclusion> unmodifiableRefMap(Map<String, ParamsBuilder> fieldBuilderMap) {
 Map<String, Exclusion> fieldMap = new LinkedHashMap<>();
 for (Map.Entry<String, ParamsBuilder> fieldEntry : fieldBuilderMap.entrySet()) {
  fieldMap.put(fieldEntry.getKey(), new Exclusion(fieldEntry.getValue()));
 }
 return unmodifiableMap(fieldMap);
}
origin: square/okhttp

private static Map<ByteString, Integer> nameToFirstIndex() {
 Map<ByteString, Integer> result = new LinkedHashMap<>(STATIC_HEADER_TABLE.length);
 for (int i = 0; i < STATIC_HEADER_TABLE.length; i++) {
  if (!result.containsKey(STATIC_HEADER_TABLE[i].name)) {
   result.put(STATIC_HEADER_TABLE[i].name, i);
  }
 }
 return Collections.unmodifiableMap(result);
}
origin: wildfly/wildfly

@Override
public JsonGeneratorFactory createGeneratorFactory(Map<String, ?> config) {
  Map<String, Object> providerConfig;
  boolean prettyPrinting;
  BufferPool pool;
  if (config == null) {
    providerConfig = Collections.emptyMap();
    prettyPrinting = false;
    pool = bufferPool;
  } else {
    providerConfig = new HashMap<>();
    if (prettyPrinting=JsonProviderImpl.isPrettyPrintingEnabled(config)) {
      providerConfig.put(JsonGenerator.PRETTY_PRINTING, true);
    }
    pool = (BufferPool)config.get(BufferPool.class.getName());
    if (pool != null) {
      providerConfig.put(BufferPool.class.getName(), pool);
    } else {
      pool = bufferPool;
    }
    providerConfig = Collections.unmodifiableMap(providerConfig);
  }
  return new JsonGeneratorFactoryImpl(providerConfig, prettyPrinting, pool);
}
origin: thymeleaf/thymeleaf

static Map<String,String> resolveMessagesForOrigin(final Class<?> origin, final Locale locale) {
  final Map<String,String> combinedMessages = new HashMap<String, String>(20);
  Class<?> currentClass = origin;
  combinedMessages.putAll(resolveMessagesForSpecificClass(currentClass, locale));
  while (!currentClass.getSuperclass().equals(Object.class)) {
    currentClass = currentClass.getSuperclass();
    final Map<String,String> messagesForCurrentClass = resolveMessagesForSpecificClass(currentClass, locale);
    for (final String messageKey : messagesForCurrentClass.keySet()) {
      if (!combinedMessages.containsKey(messageKey)) {
        combinedMessages.put(messageKey, messagesForCurrentClass.get(messageKey));
      }
    }
  }
  return Collections.unmodifiableMap(combinedMessages);
}
origin: wildfly/wildfly

  @Override
  public Map<String, String> getProperties(Class<? extends Protocol> protocolClass) {
    Map<String, String> properties = this.map.get(protocolClass);
    return (properties != null) ? Collections.unmodifiableMap(properties) : Collections.<String, String>emptyMap();
  }
}
java.utilCollectionsunmodifiableMap

Javadoc

Returns a wrapper on the specified map which throws an UnsupportedOperationException whenever an attempt is made to modify the 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
  • emptyMap
    Returns the empty map (immutable). This map is serializable.This example illustrates the type-safe w
  • emptySet
    Returns the empty set (immutable). This set is serializable. Unlike the like-named field, this metho
  • 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

  • Making http requests using okhttp
  • scheduleAtFixedRate (ScheduledExecutorService)
  • onCreateOptionsMenu (Activity)
  • getExternalFilesDir (Context)
  • EOFException (java.io)
    Thrown when a program encounters the end of a file or stream during an input operation.
  • FileOutputStream (java.io)
    An output stream that writes bytes to a file. If the output file exists, it can be replaced or appen
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • UnknownHostException (java.net)
    Thrown when a hostname can not be resolved.
  • BitSet (java.util)
    The BitSet class implements abit array [http://en.wikipedia.org/wiki/Bit_array]. Each element is eit
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • 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