|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.netflix.astyanax.mapping.Mapping<T>
public class Mapping<T>
Utility for doing object/relational mapping between bean-like instances and Cassandra
The mapper stores values in Cassandra and maps in/out to native types. Column
names must be strings. Annotate your bean with Id
and Column
. Or, provide
an AnnotationSet
that defines IDs and Columns in your bean.
Field Summary | |
---|---|
static String |
DEFAULT_ID_COLUMN_NAME
If the ID column does not have a Column annotation, this column name is used |
Constructor Summary | |
---|---|
Mapping(Class<T> clazz)
|
|
Mapping(Class<T> clazz,
AnnotationSet<?,?> annotationSet)
|
Method Summary | ||
---|---|---|
void |
fillMutation(T instance,
ColumnListMutation<String> mutation)
Map a bean to a column mutation. |
|
List<T> |
getAll(Rows<?,String> rows)
Load a set of rows into new instances populated with values from the column lists |
|
|
getColumnValue(T instance,
String columnName,
Class<V> valueClass)
Return the value for the given column from the given instance |
|
|
getIdValue(T instance,
Class<V> valueClass)
Return the value for the ID/Key column from the given instance |
|
Collection<String> |
getNames()
Return the set of column names discovered from the bean class |
|
T |
initInstance(T instance,
ColumnList<String> columns)
Populate the given instance with the values from the given column list |
|
static
|
make(Class<T> clazz)
Convenience for allocation a mapping object |
|
static
|
make(Class<T> clazz,
AnnotationSet<?,?> annotationSet)
Convenience for allocation a mapping object |
|
T |
newInstance(ColumnList<String> columns)
Allocate a new instance and populate it with the values from the given column list |
|
|
setColumnValue(T instance,
String columnName,
V value)
Set the value for the given column for the given instance |
|
|
setIdValue(T instance,
V value)
Set the value for the ID/Key column for the given instance |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final String DEFAULT_ID_COLUMN_NAME
Constructor Detail |
---|
public Mapping(Class<T> clazz)
clazz
- clazz type to mappublic Mapping(Class<T> clazz, AnnotationSet<?,?> annotationSet)
clazz
- clazz type to mapannotationSet
- annotations to use when analyzing a beanMethod Detail |
---|
public static <T> Mapping<T> make(Class<T> clazz)
clazz
- clazz type to map
public static <T> Mapping<T> make(Class<T> clazz, AnnotationSet<?,?> annotationSet)
clazz
- clazz type to mapannotationSet
- annotations to use when analyzing a bean
public <V> V getIdValue(T instance, Class<V> valueClass)
instance
- the instancevalueClass
- type of the value (must match the actual native type in the instance's class)
public <V> V getColumnValue(T instance, String columnName, Class<V> valueClass)
instance
- the instancecolumnName
- name of the column (must match a corresponding annotated field in the instance's class)valueClass
- type of the value (must match the actual native type in the instance's class)
public <V> void setIdValue(T instance, V value)
instance
- the instancevalue
- The value (must match the actual native type in the instance's class)public <V> void setColumnValue(T instance, String columnName, V value)
instance
- the instancecolumnName
- name of the column (must match a corresponding annotated field in the instance's class)value
- The value (must match the actual native type in the instance's class)public void fillMutation(T instance, ColumnListMutation<String> mutation)
instance
- instancemutation
- mutationpublic T newInstance(ColumnList<String> columns) throws IllegalAccessException, InstantiationException
columns
- column list
IllegalAccessException
- if a new instance could not be instantiated
InstantiationException
- if a new instance could not be instantiatedpublic T initInstance(T instance, ColumnList<String> columns)
instance
- instancecolumns
- column this
public List<T> getAll(Rows<?,String> rows) throws InstantiationException, IllegalAccessException
rows
- the rows
IllegalAccessException
- if a new instance could not be instantiated
InstantiationException
- if a new instance could not be instantiatedpublic Collection<String> getNames()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |