bson/src/main/org/bson/Document.java
@SuppressWarnings("unchecked")
    public <T> T get(final Object key, final T defaultValue) {
        notNull("defaultValue", defaultValue);
        Object value = documentAsMap.get(key);
        return value == null ? defaultValue : (T) value;
    }
@SuppressWarnings("unchecked")
    public <T> T get(final Object key, final T defaultValue) {
        notNull("defaultValue", defaultValue);
        Object value = documentAsMap.get(key);
        return value == null ? defaultValue : (T) value;
    }
Gets the value of the given key, casting it to {@code Class<T>} or returning the default value if null.
This is useful to avoid having casts in client code, though the effect is the same.

@param key   the key
@param defaultValue what to return if the value is null
@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
@since 3.5