1 package org.bouncycastle.util; 2 3 /** 4 * Interface for Memoable objects. Memoable objects allow the taking of a snapshot of their internal state 5 * via the copy() method and then reseting the object back to that state later using the reset() method. 6 */ 7 public interface Memoable 8 { 9 /** 10 * Produce a copy of this object with its configuration and in its current state. 11 * <p> 12 * The returned object may be used simply to store the state, or may be used as a similar object 13 * starting from the copied state. 14 */ copy()15 Memoable copy(); 16 17 /** 18 * Restore a copied object state into this object. 19 * <p> 20 * Implementations of this method <em>should</em> try to avoid or minimise memory allocation to perform the reset. 21 * 22 * @param other an object originally {@link #copy() copied} from an object of the same type as this instance. 23 * @throws ClassCastException if the provided object is not of the correct type. 24 * @throws MemoableResetException if the <b>other</b> parameter is in some other way invalid. 25 */ reset(Memoable other)26 void reset(Memoable other); 27 } 28