summaryrefslogtreecommitdiff
path: root/src/main/java/com/amazon/carbonado/Derived.java
diff options
context:
space:
mode:
authorBrian S. O'Neill <bronee@gmail.com>2007-04-29 17:47:50 +0000
committerBrian S. O'Neill <bronee@gmail.com>2007-04-29 17:47:50 +0000
commit97af4be638e371a2f693bde2798fc233a143f3f9 (patch)
tree533f5d02f91eaf1db500ed4480be23b1712d214d /src/main/java/com/amazon/carbonado/Derived.java
parent1f04eea48231dbc29ed39c100a9d4a7c7f8a8b37 (diff)
Merged in support for derived properties.
Diffstat (limited to 'src/main/java/com/amazon/carbonado/Derived.java')
-rw-r--r--src/main/java/com/amazon/carbonado/Derived.java62
1 files changed, 62 insertions, 0 deletions
diff --git a/src/main/java/com/amazon/carbonado/Derived.java b/src/main/java/com/amazon/carbonado/Derived.java
new file mode 100644
index 0000000..77ffd2a
--- /dev/null
+++ b/src/main/java/com/amazon/carbonado/Derived.java
@@ -0,0 +1,62 @@
+/*
+ * Copyright 2007 Amazon Technologies, Inc. or its affiliates.
+ * Amazon, Amazon.com and Carbonado are trademarks or registered trademarks
+ * of Amazon Technologies, Inc. or its affiliates. All rights reserved.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.amazon.carbonado;
+
+import java.lang.annotation.*;
+
+/**
+ * Identifies a {@link Storable} property which is not directly persisted, but
+ * is instead derived from other property values. A derived property cannot be
+ * abstract, and a "set" method is optional.
+ *
+ * <p>Derived properties can be used just like a normal property in most
+ * cases. They can be used in query filters, indexes, alternate keys, and they
+ * can also be used to define a {@link Version} property.
+ *
+ * <p>If the derived property depends on {@link Join} properties and is also
+ * used in an index or alternate key, dependencies must be listed in order for
+ * the index to be properly updated.
+ *
+ * <p>Example:<pre>
+ * &#64;Indexes(&#64;Index("uppercaseName"))
+ * public abstract class UserInfo implements Storable&lt;UserInfo&gt; {
+ * /**
+ * * Derive an uppercase name for case-insensitive searches.
+ * *&#47;
+ * <b>&#64;Derived</b>
+ * public String getUppercaseName() {
+ * String name = getName();
+ * return name == null ? null : name.toUpperCase();
+ * }
+ *
+ * ...
+ * }
+ * </pre>
+ *
+ * @author Brian S O'Neill
+ */
+@Documented
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Derived {
+ /**
+ * List of properties that this property is derived from.
+ */
+ String[] from() default {};
+}