From 38e97f991ee69afd53f36fd7296b4afd5a621311 Mon Sep 17 00:00:00 2001 From: Ben Culkin Date: Mon, 16 Nov 2020 18:31:29 -0500 Subject: Add interface for freezing/thawing objects This adds a new interface IFreezable, which denotes that your object supports being 'frozen' (immutable) or 'thawed' (mutable). There is also optional support for 'deep-freezing' objects, which disables the ability to thaw them. It also introduces a new exception called ObjectFrozen, which implementations of IFreezable may or may not throw when you attempt to modify a frozen object --- src/main/java/bjc/funcdata/ObjectFrozen.java | 47 ++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 src/main/java/bjc/funcdata/ObjectFrozen.java (limited to 'src/main/java/bjc/funcdata/ObjectFrozen.java') diff --git a/src/main/java/bjc/funcdata/ObjectFrozen.java b/src/main/java/bjc/funcdata/ObjectFrozen.java new file mode 100644 index 0000000..2260a0e --- /dev/null +++ b/src/main/java/bjc/funcdata/ObjectFrozen.java @@ -0,0 +1,47 @@ +package bjc.funcdata; + +/** + * Exception that implementations of {@link IFreezable} can throw if you attempt + * to modify a frozen object. + * + * @author Ben Culkin + * + */ +public class ObjectFrozen extends RuntimeException { + private static final long serialVersionUID = -1567447627139090728L; + + /** + * Create a new ObjectFrozen exception. + */ + public ObjectFrozen() { + super(); + } + + /** + * Create a new ObjectFrozen exception. + * + * @param message The message of the exception. + */ + public ObjectFrozen(String message) { + super(message); + } + + /** + * Create a new ObjectFrozen exception. + * + * @param cause The root cause of this exception. + */ + public ObjectFrozen(Throwable cause) { + super(cause); + } + + /** + * Create a new ObjectFrozen exception. + * + * @param message The message of the exception. + * @param cause The root cause of this exception. + */ + public ObjectFrozen(String message, Throwable cause) { + super(message, cause); + } +} -- cgit v1.2.3