Class StaticCache


  • public class StaticCache
    extends Object
    Stores the mutable state of a class, allowing it to be saved, printed and restored.
    • Field Detail

      • declaringClass

        private final Class<?> declaringClass
        The class for which static state is to be saved.
      • valueMap

        private final Map<Field,​Object> valueMap
        The map from static fields to a value.
    • Constructor Detail

      • StaticCache

        public StaticCache​(Class<?> declaringClass)
        Creates the cache object for a particular class. State is not saved until saveState() is called.
        Parameters:
        declaringClass - the class
    • Method Detail

      • printCache

        public void printCache()
        Prints the fields and their values to standard output.
      • saveState

        public void saveState()
        Saves the state for the class in this object. Only saves non-final static fields.
      • restoreState

        public void restoreState()
        Restores the saved state of the class in this object to previously saved values.