com.amazon.carbonado
Annotation Type Derived


@Documented
@Retention(value=RUNTIME)
@Target(value=METHOD)
public @interface Derived

Identifies a 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.

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 Version property.

If the derived property depends on 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.

Example:

 @Indexes(@Index("uppercaseName"))
 public abstract class UserInfo implements Storable<UserInfo> {
     /**
      * Derive an uppercase name for case-insensitive searches.
      */
     @Derived
     public String getUppercaseName() {
         String name = getName();
         return name == null ? null : name.toUpperCase();
     }

     ...
 }
 

Since:
1.2
Author:
Brian S O'Neill, Tobias Holgers

Optional Element Summary
 String[] from
          List of properties that this property is derived from.
 boolean shouldCopy
          Returns whether this property should be included when copying a storable.
 

from

public abstract String[] from
List of properties that this property is derived from.

Default:
{}

shouldCopy

public abstract boolean shouldCopy
Returns whether this property should be included when copying a storable. Copying of a derived property uses the "get" and "set" methods and requires the "set" method to be defined. Default false.

Default:
false


Copyright © 2006-2009 Amazon Technologies, Inc.. All Rights Reserved.