Tabnine Logo
Collections$CheckedMap
Code IndexAdd Tabnine to your IDE (free)

How to use
Collections$CheckedMap
in
java.util

Best Java code snippets using java.util.Collections$CheckedMap (Showing top 16 results out of 315)

origin: jtulach/bck2brwsr

private void typeCheck(Object key, Object value) {
  if (key != null && !keyType.isInstance(key))
    throw new ClassCastException(badKeyMsg(key));
  if (value != null && !valueType.isInstance(value))
    throw new ClassCastException(badValueMsg(value));
}
origin: jtulach/bck2brwsr

@SuppressWarnings("unchecked")
public void putAll(Map<? extends K, ? extends V> t) {
  // Satisfy the following goals:
  // - good diagnostics in case of type mismatch
  // - all-or-nothing semantics
  // - protection from malicious t
  // - correct behavior if t is a concurrent map
  Object[] entries = t.entrySet().toArray();
  List<Map.Entry<K,V>> checked = new ArrayList<>(entries.length);
  for (Object o : entries) {
    Map.Entry<?,?> e = (Map.Entry<?,?>) o;
    Object k = e.getKey();
    Object v = e.getValue();
    typeCheck(k, v);
    checked.add(
      new AbstractMap.SimpleImmutableEntry<>((K) k, (V) v));
  }
  for (Map.Entry<K,V> e : checked)
    m.put(e.getKey(), e.getValue());
}
origin: jtulach/bck2brwsr

                   Class<K> keyType,
                   Class<V> valueType) {
return new CheckedMap<>(m, keyType, valueType);
origin: org.apidesign.bck2brwsr/emul

                   Class<K> keyType,
                   Class<V> valueType) {
return new CheckedMap<>(m, keyType, valueType);
origin: org.apidesign.bck2brwsr/emul

@SuppressWarnings("unchecked")
public void putAll(Map<? extends K, ? extends V> t) {
  // Satisfy the following goals:
  // - good diagnostics in case of type mismatch
  // - all-or-nothing semantics
  // - protection from malicious t
  // - correct behavior if t is a concurrent map
  Object[] entries = t.entrySet().toArray();
  List<Map.Entry<K,V>> checked = new ArrayList<>(entries.length);
  for (Object o : entries) {
    Map.Entry<?,?> e = (Map.Entry<?,?>) o;
    Object k = e.getKey();
    Object v = e.getValue();
    typeCheck(k, v);
    checked.add(
      new AbstractMap.SimpleImmutableEntry<>((K) k, (V) v));
  }
  for (Map.Entry<K,V> e : checked)
    m.put(e.getKey(), e.getValue());
}
origin: com.bugvm/bugvm-rt

/**
 * Returns a dynamically typesafe view of the specified map. Trying to
 * insert an element of the wrong type into this map throws a
 * {@code ClassCastException}. At creation time the types in {@code m} are
 * not checked for correct type.
 *
 * @param m
 *            the map to be wrapped in a typesafe map.
 * @param keyType
 *            the type of the keys permitted to insert.
 * @param valueType
 *            the type of the values permitted to insert.
 * @return a typesafe map.
 */
public static <K, V> Map<K, V> checkedMap(Map<K, V> m, Class<K> keyType,
    Class<V> valueType) {
  return new CheckedMap<K, V>(m, keyType, valueType);
}
origin: com.mobidevelop.robovm/robovm-rt

/**
 * Returns a dynamically typesafe view of the specified map. Trying to
 * insert an element of the wrong type into this map throws a
 * {@code ClassCastException}. At creation time the types in {@code m} are
 * not checked for correct type.
 *
 * @param m
 *            the map to be wrapped in a typesafe map.
 * @param keyType
 *            the type of the keys permitted to insert.
 * @param valueType
 *            the type of the values permitted to insert.
 * @return a typesafe map.
 */
public static <K, V> Map<K, V> checkedMap(Map<K, V> m, Class<K> keyType,
    Class<V> valueType) {
  return new CheckedMap<K, V>(m, keyType, valueType);
}
origin: ibinti/bugvm

/**
 * Returns a dynamically typesafe view of the specified map. Trying to
 * insert an element of the wrong type into this map throws a
 * {@code ClassCastException}. At creation time the types in {@code m} are
 * not checked for correct type.
 *
 * @param m
 *            the map to be wrapped in a typesafe map.
 * @param keyType
 *            the type of the keys permitted to insert.
 * @param valueType
 *            the type of the values permitted to insert.
 * @return a typesafe map.
 */
public static <K, V> Map<K, V> checkedMap(Map<K, V> m, Class<K> keyType,
    Class<V> valueType) {
  return new CheckedMap<K, V>(m, keyType, valueType);
}
origin: com.gluonhq/robovm-rt

/**
 * Returns a dynamically typesafe view of the specified map. Trying to
 * insert an element of the wrong type into this map throws a
 * {@code ClassCastException}. At creation time the types in {@code m} are
 * not checked for correct type.
 *
 * @param m
 *            the map to be wrapped in a typesafe map.
 * @param keyType
 *            the type of the keys permitted to insert.
 * @param valueType
 *            the type of the values permitted to insert.
 * @return a typesafe map.
 */
public static <K, V> Map<K, V> checkedMap(Map<K, V> m, Class<K> keyType,
    Class<V> valueType) {
  return new CheckedMap<K, V>(m, keyType, valueType);
}
origin: com.jtransc/jtransc-rt

/**
 * Returns a dynamically typesafe view of the specified map. Trying to
 * insert an element of the wrong type into this map throws a
 * {@code ClassCastException}. At creation time the types in {@code m} are
 * not checked for correct type.
 *
 * @param m
 *            the map to be wrapped in a typesafe map.
 * @param keyType
 *            the type of the keys permitted to insert.
 * @param valueType
 *            the type of the values permitted to insert.
 * @return a typesafe map.
 */
public static <K, V> Map<K, V> checkedMap(Map<K, V> m, Class<K> keyType,
    Class<V> valueType) {
  return new CheckedMap<K, V>(m, keyType, valueType);
}
origin: MobiVM/robovm

/**
 * Returns a dynamically typesafe view of the specified map. Trying to
 * insert an element of the wrong type into this map throws a
 * {@code ClassCastException}. At creation time the types in {@code m} are
 * not checked for correct type.
 *
 * @param m
 *            the map to be wrapped in a typesafe map.
 * @param keyType
 *            the type of the keys permitted to insert.
 * @param valueType
 *            the type of the values permitted to insert.
 * @return a typesafe map.
 */
public static <K, V> Map<K, V> checkedMap(Map<K, V> m, Class<K> keyType,
    Class<V> valueType) {
  return new CheckedMap<K, V>(m, keyType, valueType);
}
origin: FlexoVM/flexovm

/**
 * Returns a dynamically typesafe view of the specified map. Trying to
 * insert an element of the wrong type into this map throws a
 * {@code ClassCastException}. At creation time the types in {@code m} are
 * not checked for correct type.
 *
 * @param m
 *            the map to be wrapped in a typesafe map.
 * @param keyType
 *            the type of the keys permitted to insert.
 * @param valueType
 *            the type of the values permitted to insert.
 * @return a typesafe map.
 */
public static <K, V> Map<K, V> checkedMap(Map<K, V> m, Class<K> keyType,
    Class<V> valueType) {
  return new CheckedMap<K, V>(m, keyType, valueType);
}
origin: org.apidesign.bck2brwsr/emul

public V put(K key, V value) {
  typeCheck(key, value);
  return m.put(key, value);
}
origin: jtulach/bck2brwsr

public V put(K key, V value) {
  typeCheck(key, value);
  return m.put(key, value);
}
origin: org.apidesign.bck2brwsr/emul

private void typeCheck(Object key, Object value) {
  if (key != null && !keyType.isInstance(key))
    throw new ClassCastException(badKeyMsg(key));
  if (value != null && !valueType.isInstance(value))
    throw new ClassCastException(badValueMsg(value));
}
origin: robovm/robovm

/**
 * Returns a dynamically typesafe view of the specified map. Trying to
 * insert an element of the wrong type into this map throws a
 * {@code ClassCastException}. At creation time the types in {@code m} are
 * not checked for correct type.
 *
 * @param m
 *            the map to be wrapped in a typesafe map.
 * @param keyType
 *            the type of the keys permitted to insert.
 * @param valueType
 *            the type of the values permitted to insert.
 * @return a typesafe map.
 */
public static <K, V> Map<K, V> checkedMap(Map<K, V> m, Class<K> keyType,
    Class<V> valueType) {
  return new CheckedMap<K, V>(m, keyType, valueType);
}
java.utilCollections$CheckedMap

Javadoc

A dynamically typesafe view of a Map.

Most used methods

  • <init>
  • badKeyMsg
  • badValueMsg
  • typeCheck

Popular in Java

  • Updating database using SQL prepared statement
  • setContentView (Activity)
  • getApplicationContext (Context)
  • getOriginalFilename (MultipartFile)
    Return the original filename in the client's filesystem.This may contain path information depending
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Runnable (java.lang)
    Represents a command that can be executed. Often used to run code in a different Thread.
  • NumberFormat (java.text)
    The abstract base class for all number formats. This class provides the interface for formatting and
  • Collection (java.util)
    Collection is the root of the collection hierarchy. It defines operations on data collections and t
  • Callable (java.util.concurrent)
    A task that returns a result and may throw an exception. Implementors define a single method with no
  • Join (org.hibernate.mapping)
  • Top Vim plugins
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