diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2012-09-25 02:33:25 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2012-09-25 02:33:25 +0000 |
commit | 670711f96a0b78cb674aaa090e965922e028d276 (patch) | |
tree | 364daa14ae8affd9759e4af88a4883f7b626f981 /src/main/java/com | |
parent | 36f24e909e0c1bec928c04e41c838e91da6d61bf (diff) |
Support instantiation by just the key.
Diffstat (limited to 'src/main/java/com')
-rw-r--r-- | src/main/java/com/amazon/carbonado/raw/GenericStorableCodec.java | 12 | ||||
-rw-r--r-- | src/main/java/com/amazon/carbonado/raw/StorableCodec.java | 9 |
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.
*
|