base/common/src/main/com/thesett/common/reflect/DirectMemento.java
public void restore(Object ob) throws NoSuchFieldException
    {
        /*log.fine("public void map(Object ob): called");*/
        /*log.fine("class is " + ob.getClass());*/

        // Iterate over the whole inheritence chain.
        for (Object key : values.keySet())
        {
            // Get the next class from the cache.
            Class cls = (Class) key;

            // Get the cache of field values for the class.
            Map vals = (HashMap) values.get(cls);

            // Loop over all fields in the class.
            for (Object o : vals.keySet())
            {
                // Get the next field name.
                String attr = (String) o;

                // Get the next field value.
                Object val = vals.get(attr);

                // Get a reference to the field in the object.
                Field f = cls.getDeclaredField(attr);

                // Make the field accessible (it may be protected, package or private).
                f.setAccessible(true);

                // Use a try block as writing to the field may fail.
                try
                {
                    // Write to the field.
                    f.set(ob, val);
                }
                catch (IllegalAccessException e)
                {
                    // The field could not be written to but all fields have been made accessible so this should
                    // not happen.
                    throw new IllegalStateException("Field '" + f.getName() +
                        "' could not be accessed but the 'setAccessible(true)' method was invoked on it.", e);
                }
            }
        }
    }
public void restore(Object ob) throws NoSuchFieldException
    {
        /*log.fine("public void map(Object ob): called");*/
        /*log.fine("class is " + ob.getClass());*/

        // Iterate over the whole inheritence chain.
        for (Object key : values.keySet())
        {
            // Get the next class from the cache.
            Class cls = (Class) key;

            // Get the cache of field values for the class.
            Map vals = (HashMap) values.get(cls);

            // Loop over all fields in the class.
            for (Object o : vals.keySet())
            {
                // Get the next field name.
                String attr = (String) o;

                // Get the next field value.
                Object val = vals.get(attr);

                // Get a reference to the field in the object.
                Field f = cls.getDeclaredField(attr);

                // Make the field accessible (it may be protected, package or private).
                f.setAccessible(true);

                // Use a try block as writing to the field may fail.
                try
                {
                    // Write to the field.
                    f.set(ob, val);
                }
                catch (IllegalAccessException e)
                {
                    // The field could not be written to but all fields have been made accessible so this should
                    // not happen.
                    throw new IllegalStateException("Field '" + f.getName() +
                        "' could not be accessed but the 'setAccessible(true)' method was invoked on it.", e);
                }
            }
        }
    }
Restores the values currently in this memento to the specified object.

@param  ob The object to which the values from this memento should be restored.

@throws NoSuchFieldException If the object in question does not have a field for one of the memento values.