public class

ClassMap

extends Object
java.lang.Object
   ↳ org.bson.util.ClassMap<T>

Class Overview

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)

Summary

Public Constructors
ClassMap()
Public Methods
void clear()
T get(Object key)
static <T> List<Class<?>> getAncestry(Class<T> c)
Walks superclass and interface graph, superclasses first, then interfaces, to compute an ancestry list.
boolean isEmpty()
T put(Class<?> key, T value)
T remove(Object key)
int size()
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public ClassMap ()

Public Methods

public void clear ()

public T get (Object key)

public static List<Class<?>> getAncestry (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.

public boolean isEmpty ()

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

public T remove (Object key)

public int size ()