summaryrefslogtreecommitdiff
path: root/src/main/java/bjc/funcdata/ObjectFrozen.java
diff options
context:
space:
mode:
authorBen Culkin <scorpress@gmail.com>2020-11-16 18:31:29 -0500
committerBen Culkin <scorpress@gmail.com>2020-11-16 18:31:29 -0500
commit38e97f991ee69afd53f36fd7296b4afd5a621311 (patch)
treeb67927e18f2c02d172bf3d01d5b60df42e33f200 /src/main/java/bjc/funcdata/ObjectFrozen.java
parentcd4487c1e3b50fdd8aa4a3cc81edf665c86507ca (diff)
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
Diffstat (limited to 'src/main/java/bjc/funcdata/ObjectFrozen.java')
-rw-r--r--src/main/java/bjc/funcdata/ObjectFrozen.java47
1 files changed, 47 insertions, 0 deletions
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);
+ }
+}