T
- the class of instances that are serialized into the databasepublic static class DatabaseStorage.BeanPropertyColumnConvertor<T> extends java.lang.Object implements DatabaseStorage.SearchableColumnConvertor<java.lang.Object,T>
Constructor and Description |
---|
DatabaseStorage.BeanPropertyColumnConvertor(java.lang.String propertyName,
java.lang.Class<? extends T> storedObjectsClass,
boolean usedToRead,
boolean usedToWrite)
Creates a new instance of BeanPropertyColumnConvertor.
|
Modifier and Type | Method and Description |
---|---|
T |
convertFromColumnValue(T value,
java.lang.Object column)
Returns an instance of object from the database column value.
|
java.lang.Object |
convertKeyToColumnValue(java.lang.Object key)
Returns a column value that can be used to search inside the database.
|
java.lang.Object |
convertToColumnValue(T instance)
Returns a value that can be stored in a database column for the given instance.
|
boolean |
isColumnCompatible(IndexComparator<?,? super T> indexComparator)
Returns true if the instance created by this convertor is compatible
with the given index comparator.
|
boolean |
isConvertFromColumnUsed()
Returns whether the
convertFromColumnValue
method should be used when reading the object from the database. |
boolean |
isConvertToColumnUsed()
Returns whether the
convertToColumnValue
method should be used when writing the object to database. |
public DatabaseStorage.BeanPropertyColumnConvertor(java.lang.String propertyName, java.lang.Class<? extends T> storedObjectsClass, boolean usedToRead, boolean usedToWrite) throws java.lang.IllegalArgumentException
propertyName
- the name of the property of the storedObjectsClass
to usestoredObjectsClass
- the class of instances that are serialized by this column convertorusedToRead
- a flag whether this column convertor is used (true) or should be skipped (false) when the object is retrieved from the storageusedToWrite
- a flag whether this column convertor is used (true) or should be skipped (false) when the object is stored into the storagejava.lang.IllegalArgumentException
- if there was no property of the given name in storedObjectsClass
public java.lang.Object convertToColumnValue(T instance) throws BucketStorageException
DatabaseStorage.ColumnConvertor
convertToColumnValue
in interface DatabaseStorage.ColumnConvertor<T>
instance
- the object instance from which to create a database valueBucketStorageException
- if the value cannot be convertedpublic boolean isConvertToColumnUsed()
DatabaseStorage.ColumnConvertor
convertToColumnValue
method should be used when writing the object to database.isConvertToColumnUsed
in interface DatabaseStorage.ColumnConvertor<T>
public T convertFromColumnValue(T value, java.lang.Object column) throws BucketStorageException
DatabaseStorage.ColumnConvertor
value
, which can
be either replaced by a new value, modified by this method or left intact.convertFromColumnValue
in interface DatabaseStorage.ColumnConvertor<T>
value
- the instance created by previous column convertorscolumn
- the value of the column to convertBucketStorageException
- if the value cannot be convertedpublic boolean isConvertFromColumnUsed()
DatabaseStorage.ColumnConvertor
convertFromColumnValue
method should be used when reading the object from the database.isConvertFromColumnUsed
in interface DatabaseStorage.ColumnConvertor<T>
public boolean isColumnCompatible(IndexComparator<?,? super T> indexComparator)
DatabaseStorage.SearchableColumnConvertor
isColumnCompatible
in interface DatabaseStorage.SearchableColumnConvertor<java.lang.Object,T>
indexComparator
- the index comparator that is checked for compatibilitypublic java.lang.Object convertKeyToColumnValue(java.lang.Object key)
DatabaseStorage.SearchableColumnConvertor
convertKeyToColumnValue
in interface DatabaseStorage.SearchableColumnConvertor<java.lang.Object,T>
key
- the key from which to create a database value