Interface Transformer
- All Known Subinterfaces:
Filter
- Functional Interface:
- This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.
-
Method Summary
Modifier and TypeMethodDescriptiondefault byte[]
inverseTransformKey
(byte[] tkey) Apply an inverse transformation of the given key, if supported.default byte[]
inverseTransformKeyGt
(byte[] tkey) Apply an inverse transformation of the given key, strictly greater than the one given.default byte[]
inverseTransformKeyLt
(byte[] tkey) Apply an inverse transformation of the given key, strictly less than the one given.default byte[]
inverseTransformValue
(byte[] tvalue, byte[] key, byte[] tkey) Apply an inverse transformation of the given value, if supported.default Boolean
Returns true by default, indicating that the transform methods always require a value instance to be provided.default Comparator
<byte[]> transformedComparator
(Comparator<byte[]> original) Returns the view comparator, after transformation.default Ordering
transformedOrdering
(Ordering original) Returns the natural ordering of keys, after they have been transformed.default byte[]
transformKey
(Cursor cursor) Transform or filter out the given key.byte[]
transformValue
(byte[] value, byte[] key, byte[] tkey) Transform or filter out the given value.default byte[]
transformValue
(Cursor cursor, byte[] tkey) Transform or filter out the given value.
-
Method Details
-
requireValue
Returns true by default, indicating that the transform methods always require a value instance to be provided. When false is returned, values aren't loaded unless explicitly requested. Return null to always use a cursor, in which case thetransformValue
variant which accepts a cursor should be overridden. Otherwise, returning null is equivalent to returning true.- Returns:
- true if a value must always be passed into the transform methods
-
transformValue
Transform or filter out the given value. This method is only called when loading a value from a view.- Parameters:
value
- nullable value to transformkey
- non-null untransformed key associated with the valuetkey
- non-null transformed key associated with the value- Returns:
- transformed value or null to discard entry
- Throws:
IOException
-
transformValue
Transform or filter out the given value. This method is only called when loading from a positioned a cursor. Default implementation always forces the value to be loaded, unlessrequireValue
returns false.- Parameters:
cursor
- positioned cursor at the untransformed key and value (not null, might beNOT_LOADED
)tkey
- non-null transformed key associated with the value- Returns:
- transformed value or null to discard entry
- Throws:
IOException
-
inverseTransformValue
default byte[] inverseTransformValue(byte[] tvalue, byte[] key, byte[] tkey) throws ViewConstraintException, IOException Apply an inverse transformation of the given value, if supported. This method is only called when attempting to store the value into the view. Default implementation always throws aViewConstraintException
.- Parameters:
tvalue
- nullable value to transformkey
- non-null untransformed key associated with the valuetkey
- non-null transformed key associated with the value- Returns:
- inverse transformed value, or null to delete the value
- Throws:
ViewConstraintException
- if inverse transformation of given value is not supportedIOException
-
transformKey
Transform or filter out the given key. This method is only called after positioning a cursor. Default implementation returns the same key.- Parameters:
cursor
- positioned cursor at the untransformed key and value (might be null orNOT_LOADED
)- Returns:
- transformed key or null to discard entry
- Throws:
IOException
-
inverseTransformKey
default byte[] inverseTransformKey(byte[] tkey) Apply an inverse transformation of the given key, if supported. This method can be called for load and store operations. Default implementation returns the same key.- Parameters:
tkey
- non-null key- Returns:
- inverse transformed key or null if inverse transformation of given key is not supported
-
inverseTransformKeyGt
default byte[] inverseTransformKeyGt(byte[] tkey) Apply an inverse transformation of the given key, strictly greater than the one given. This method is only called after the regular inverse transformation has been attempted. Default implementation increments the key by the minimum amount and then calls inverseTransformKey.- Parameters:
tkey
- non-null key- Returns:
- inverse transformed key or null if inverse transformation of given key is not supported
-
inverseTransformKeyLt
default byte[] inverseTransformKeyLt(byte[] tkey) Apply an inverse transformation of the given key, strictly less than the one given. This method is only called after the regular inverse transformation has been attempted. Default implementation decrements the key by the minimum amount and then calls inverseTransformKey.- Parameters:
tkey
- non-null key- Returns:
- inverse transformed key or null if inverse transformation of given key is not supported
-
transformedOrdering
-
transformedComparator
Returns the view comparator, after transformation. Default implementation returns the same comparator.- Parameters:
original
- comparator of view before transformation- Throws:
IllegalStateException
- if transformed view is unordered
-