public static Object toPersistenceType ( Object value , Class < ? > parameterType ) { if ( ! isTypeConversionRequired ( parameterType ) ) { return value ; } if ( Map . class . isAssignableFrom ( parameterType ) && ( value instanceof Map ) ) { Map < ? , ? > map = ( Map < ? , ? > ) value ; Map . Entry < ? , ? > [ ] entries = Iterators . toArray ( map . entrySet ( ) . iterator ( ) , Map . Entry . class ) ; String [ ] stringArray = new String [ entries . length ] ; for ( int i = 0 ; i < entries . length ; i ++ ) { Map . Entry < ? , ? > entry = entries [ i ] ; String entryKey = Objects . toString ( entry . getKey ( ) , "" ) ; String entryValue = Objects . toString ( entry . getValue ( ) , "" ) ; stringArray [ i ] = ConversionStringUtils . encodeString ( entryKey ) + KEY_VALUE_DELIMITER + ConversionStringUtils . encodeString ( entryValue ) ; } return stringArray ; } throw new IllegalArgumentException ( "Type conversion not supported: " + parameterType . getName ( ) ) ; }
Convert object to be persisted .