public void writeObjectOrNull ( Output output , Object object , Serializer serializer ) { if ( output == null ) throw new IllegalArgumentException ( "output cannot be null." ) ; if ( serializer == null ) throw new IllegalArgumentException ( "serializer cannot be null." ) ; beginObject ( ) ; try { if ( references ) { if ( writeReferenceOrNull ( output , object , true ) ) return ; } else if ( ! serializer . getAcceptsNull ( ) ) { if ( object == null ) { if ( TRACE || ( DEBUG && depth == 1 ) ) log ( "Write" , null , output . position ( ) ) ; output . writeByte ( NULL ) ; return ; } if ( TRACE ) trace ( "kryo" , "Write: <not null>" + pos ( output . position ( ) ) ) ; output . writeByte ( NOT_NULL ) ; } if ( TRACE || ( DEBUG && depth == 1 ) ) log ( "Write" , object , output . position ( ) ) ; serializer . write ( this , output , object ) ; } finally { if ( -- depth == 0 && autoReset ) reset ( ) ; } }
Writes an object or null using the specified serializer . The registered serializer is ignored .