public void set ( Writable obj ) { instance = obj ; Class < ? extends Writable > instanceClazz = instance . getClass ( ) ; Class < ? extends Writable > [ ] clazzes = getTypes ( ) ; for ( int i = 0 ; i < clazzes . length ; i ++ ) { Class < ? extends Writable > clazz = clazzes [ i ] ; if ( clazz . equals ( instanceClazz ) ) { type = ( byte ) i ; return ; } } throw new RuntimeException ( "The type of instance is: " + instance . getClass ( ) + ", which is NOT registered." ) ; }
Set the instance that is wrapped .