diff options
author | Brian S. O'Neill <bronee@gmail.com> | 2006-09-22 06:37:59 +0000 |
---|---|---|
committer | Brian S. O'Neill <bronee@gmail.com> | 2006-09-22 06:37:59 +0000 |
commit | b503b09219e7aad8bb5d067ccd9e09d248590451 (patch) | |
tree | 049565ff99960d81c6004647bd58f5fa02f0de81 /src/main/java/com/amazon/carbonado | |
parent | 2062d9432045c65fb2df06f55947838b24ad2613 (diff) |
Added method to get the tail of a chained property.
Diffstat (limited to 'src/main/java/com/amazon/carbonado')
-rw-r--r-- | src/main/java/com/amazon/carbonado/info/ChainedProperty.java | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/src/main/java/com/amazon/carbonado/info/ChainedProperty.java b/src/main/java/com/amazon/carbonado/info/ChainedProperty.java index e0b1121..1c4022d 100644 --- a/src/main/java/com/amazon/carbonado/info/ChainedProperty.java +++ b/src/main/java/com/amazon/carbonado/info/ChainedProperty.java @@ -213,7 +213,7 @@ public class ChainedProperty<S extends Storable> implements Appender { new StorableProperty[getChainCount() + 1 + propChainCount];
int pos = 0;
- if (newChain.length > 1) {
+ if (getChainCount() > 0) {
System.arraycopy(mChain, 0, newChain, 0, mChain.length);
pos = mChain.length;
}
@@ -243,6 +243,24 @@ public class ChainedProperty<S extends Storable> implements Appender { return get(mPrime, newChain);
}
+ /**
+ * Returns a new ChainedProperty which contains everything that follows
+ * this ChainedProperty's prime property.
+ *
+ * @throws IllegalStateException if chain count is zero
+ */
+ public ChainedProperty<?> tail() {
+ if (getChainCount() == 0) {
+ throw new IllegalStateException();
+ }
+ if (getChainCount() == 1) {
+ return get(mChain[0]);
+ }
+ StorableProperty<?>[] newChain = new StorableProperty[getChainCount() - 1];
+ System.arraycopy(mChain, 1, newChain, 0, newChain.length);
+ return get(mChain[0], newChain);
+ }
+
@Override
public int hashCode() {
int hash = mPrime.hashCode();
|