private static void setFields ( final Object from , final Object to , final Field [ ] fields , final boolean accessible , final Map objMap , final Map metadataMap ) { for ( int f = 0 , fieldsLength = fields . length ; f < fieldsLength ; ++ f ) { final Field field = fields [ f ] ; final int modifiers = field . getModifiers ( ) ; if ( ( Modifier . STATIC & modifiers ) != 0 ) continue ; if ( ( Modifier . FINAL & modifiers ) != 0 ) throw new ObjectCopyException ( "cannot set final field [" + field . getName ( ) + "] of class [" + from . getClass ( ) . getName ( ) + "]" ) ; if ( ! accessible && ( ( Modifier . PUBLIC & modifiers ) == 0 ) ) { try { field . setAccessible ( true ) ; } catch ( SecurityException e ) { throw new ObjectCopyException ( "cannot access field [" + field . getName ( ) + "] of class [" + from . getClass ( ) . getName ( ) + "]: " + e . toString ( ) , e ) ; } } try { cloneAndSetFieldValue ( field , from , to , objMap , metadataMap ) ; } catch ( Exception e ) { throw new ObjectCopyException ( "cannot set field [" + field . getName ( ) + "] of class [" + from . getClass ( ) . getName ( ) + "]: " + e . toString ( ) , e ) ; } } }
copy all fields from the from object to the to object .