bson/src/main/org/bson/BSON.java
public static void addEncodingHook(final Class<?> clazz, final Transformer transformer) {
        encodeHooks = true;
        List<Transformer> transformersForClass = encodingHooks.get(clazz);
        if (transformersForClass == null) {
            transformersForClass = new CopyOnWriteArrayList<Transformer>();
            encodingHooks.put(clazz, transformersForClass);
        }
        transformersForClass.add(transformer);
    }
public static void addEncodingHook(final Class<?> clazz, final Transformer transformer) {
        encodeHooks = true;
        List<Transformer> transformersForClass = encodingHooks.get(clazz);
        if (transformersForClass == null) {
            transformersForClass = new CopyOnWriteArrayList<Transformer>();
            encodingHooks.put(clazz, transformersForClass);
        }
        transformersForClass.add(transformer);
    }
public static void addEncodingHook ( final Class < ? > clazz , final Transformer transformer ) { encodeHooks = true ; List < Transformer > transformersForClass = encodingHooks . get ( clazz ) ; if ( transformersForClass == null ) { transformersForClass = new CopyOnWriteArrayList < Transformer > ( ) ; encodingHooks . put ( clazz , transformersForClass ) ; } transformersForClass . add ( transformer ) ; }
Registers a {@code Transformer} to use to encode a specific class into BSON.

@param clazz       the class to be transformed during encoding
@param transformer the transformer to use during encoding
Registers a { @code Transformer } to use to encode a specific class into BSON .