ClassMap
Date: 2015-03-03

org.bson.util

## Class ClassMap<T>

- java.lang.Object
- - org.bson.util.ClassMap<T>

-     public class ClassMap<T>
      extends java.lang.Object

  Maps Class objects to values. A ClassMap is different from a regular Map in that get(c) does not only look to see if 'c' is a key in the Map, but also walks the up superclass and interface graph of 'c' to find matches. Derived matches of this sort are then "cached" in the registry so that matches are faster on future gets. This is a very useful class for Class based registries. Example: ClassMap m = new ClassMap(); m.put(Animal.class, "Animal"); m.put(Fox.class, "Fox"); m.Fox.class) --> "Fox" m.get(Dog.class) --> "Animal" (assuming Dog.class < Animal.class)

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `ClassMap()`

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `clear()`
    `T` | `get(java.lang.Object key)`
    `static <T> java.util.List<java.lang.Class<?>>` | `getAncestry(java.lang.Class<T> c)` Walks superclass and interface graph, superclasses first, then interfaces, to compute an ancestry list.
    `boolean` | `isEmpty()`
    `T` | `put(java.lang.Class<?> key, T value)`
    `T` | `remove(java.lang.Object key)`
    `int` | `size()`

    - ### Methods inherited from class java.lang.Object

      `equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ClassMap

          public ClassMap()

  - ### Method Detail

    - #### getAncestry

          public static <T> java.util.List<java.lang.Class<?>> getAncestry(java.lang.Class<T> c)

      Walks superclass and interface graph, superclasses first, then interfaces, to compute an ancestry list. Supertypes are visited left to right. Duplicates are removed such that no Class will appear in the list before one of its subtypes.

    - #### get

          public T get(java.lang.Object key)

    - #### put

          public T put(java.lang.Class<?> key,
              T value)

    - #### remove

          public T remove(java.lang.Object key)

    - #### clear

          public void clear()

    - #### size

          public int size()

    - #### isEmpty

          public boolean isEmpty()