summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2012-09-25 02:33:25 +0000
committerBrian S. O'Neill <bronee@gmail.com>2012-09-25 02:33:25 +0000
commit670711f96a0b78cb674aaa090e965922e028d276 (patch)
tree364daa14ae8affd9759e4af88a4883f7b626f981 /src/main/java/com/amazon/carbonado
parent36f24e909e0c1bec928c04e41c838e91da6d61bf (diff)
Support instantiation by just the key.
Diffstat (limited to 'src/main/java/com/amazon/carbonado')
-rw-r--r--src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java12
-rw-r--r--src/main/java/com/amazon/carbonado/raw/StorableCodec.java9
2 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java b/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java
index 681909a..92a6473 100644
--- a/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java
+++ b/src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java
@@ -358,6 +358,18 @@ public class GenericStorableCodec<S extends Storable> implements StorableCodec<S
}
/**
+ * Instantiate a Storable with no value defined yet. The default {@link
+ * RawSupport} is supplied to the instance.
+ *
+ * @throws IllegalStateException if no default support exists
+ * @since 1.2
+ */
+ @SuppressWarnings("unchecked")
+ public S instantiate(byte[] key) throws FetchException {
+ return (S) mInstanceFactory.instantiate(support(), key);
+ }
+
+ /**
* Instantiate a Storable with a specific key and value. The default
* {@link RawSupport} is supplied to the instance.
*
diff --git a/src/main/java/com/amazon/carbonado/raw/StorableCodec.java b/src/main/java/com/amazon/carbonado/raw/StorableCodec.java
index 58f6531..8945861 100644
--- a/src/main/java/com/amazon/carbonado/raw/StorableCodec.java
+++ b/src/main/java/com/amazon/carbonado/raw/StorableCodec.java
@@ -45,6 +45,15 @@ public interface StorableCodec<S extends Storable> {
S instantiate();
/**
+ * Instantiate a Storable with no value defined yet. The default {@link
+ * RawSupport} is supplied to the instance.
+ *
+ * @throws IllegalStateException if no default support exists
+ * @since 1.2
+ */
+ S instantiate(byte[] key) throws FetchException;
+
+ /**
* Instantiate a Storable with a specific key and value. The default
* {@link RawSupport} is supplied to the instance.
*