bson/src/main/org/bson/Document.java
public <T> T get(final Object key, final Class<T> clazz) {
        notNull("clazz", clazz);
        return clazz.cast(documentAsMap.get(key));
    }
public <T> T get(final Object key, final Class<T> clazz) {
        notNull("clazz", clazz);
        return clazz.cast(documentAsMap.get(key));
    }
public < T > T get ( final Object key , final Class < T > clazz ) { notNull ( "clazz" , clazz ) ; return clazz . cast ( documentAsMap . get ( key ) ) ; }
Gets the value of the given key, casting it to the given {@code Class<T>}.  This is useful to avoid having casts in client code,
though the effect is the same.  So to get the value of a key that is of type String, you would write {@code String name =
doc.get("name", String.class)} instead of {@code String name = (String) doc.get("x") }.

@param key   the key
@param clazz the non-null class to cast the value to
@param <T>   the type of the class
@return the value of the given key, or null if the instance does not contain this key.
@throws ClassCastException if the value of the given key is not of type T
Gets the value of the given key casting it to the given { @code Class<T > } . This is useful to avoid having casts in client code though the effect is the same . So to get the value of a key that is of type String you would write { @code String name = doc . get ( name String . class ) } instead of { @code String name = ( String ) doc . get ( x ) } .