public ISynchronizationPoint < ? extends Exception > serializeValue ( SerializationContext context , Object value , TypeDefinition typeDef , String path , List < SerializationRule > rules ) { if ( value == null ) return serializeNullValue ( ) ; for ( SerializationRule rule : rules ) value = rule . convertSerializationValue ( value , typeDef , context ) ; Class < ? > type = value . getClass ( ) ; if ( type . isArray ( ) ) { if ( value instanceof byte [ ] ) return serializeByteArrayValue ( context , ( byte [ ] ) value , path , rules ) ; Class < ? > elementType = type . getComponentType ( ) ; CollectionContext ctx = new CollectionContext ( context , value , typeDef , new TypeDefinition ( elementType ) ) ; return serializeCollectionValue ( ctx , path , rules ) ; } if ( boolean . class . equals ( type ) || Boolean . class . equals ( type ) ) return serializeBooleanValue ( ( ( Boolean ) value ) . booleanValue ( ) ) ; if ( byte . class . equals ( type ) || short . class . equals ( type ) || int . class . equals ( type ) || long . class . equals ( type ) || float . class . equals ( type ) || double . class . equals ( type ) || Number . class . isAssignableFrom ( type ) ) return serializeNumericValue ( ( Number ) value ) ; if ( char . class . equals ( type ) || Character . class . equals ( type ) ) return serializeCharacterValue ( ( ( Character ) value ) . charValue ( ) ) ; if ( CharSequence . class . isAssignableFrom ( type ) ) return serializeStringValue ( ( CharSequence ) value ) ; if ( type . isEnum ( ) ) return serializeStringValue ( ( ( Enum < ? > ) value ) . name ( ) ) ; if ( Collection . class . isAssignableFrom ( type ) ) { TypeDefinition elementType ; if ( typeDef . getParameters ( ) . isEmpty ( ) ) elementType = null ; else elementType = typeDef . getParameters ( ) . get ( 0 ) ; CollectionContext ctx = new CollectionContext ( context , value , typeDef , elementType ) ; return serializeCollectionValue ( ctx , path , rules ) ; } if ( Map . class . isAssignableFrom ( type ) ) return serializeMapValue ( context , ( Map < ? , ? > ) value , typeDef , path , rules ) ; if ( InputStream . class . isAssignableFrom ( type ) ) return serializeInputStreamValue ( context , ( InputStream ) value , path , rules ) ; if ( IO . Readable . class . isAssignableFrom ( type ) ) return serializeIOReadableValue ( context , ( IO . Readable ) value , path , rules ) ; return serializeObjectValue ( context , value , typeDef , path , rules ) ; }
Serialize a value .