Class CacheableResultTransformer

  • All Implemented Interfaces:
    java.io.Serializable, ResultTransformer

    public class CacheableResultTransformer
    extends java.lang.Object
    implements ResultTransformer
    A ResultTransformer that is used to transform tuples to a value(s) that can be cached.
    See Also:
    Serialized Form
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static CacheableResultTransformer create​(ResultTransformer transformer, java.lang.String[] aliases, boolean[] includeInTuple)
      Returns a CacheableResultTransformer that is used to transform tuples to a value(s) that can be cached.
      boolean equals​(java.lang.Object o)  
      Type[] getCachedResultTypes​(Type[] tupleResultTypes)  
      int hashCode()  
      java.util.List retransformResults​(java.util.List transformedResults, java.lang.String[] aliases, ResultTransformer transformer, boolean[] includeInTuple)
      Re-transforms, if necessary, a List of values previously transformed by this (or an equivalent) CacheableResultTransformer.
      java.util.List transformList​(java.util.List list)
      Here we have an opportunity to perform transformation on the query result as a whole.
      java.lang.Object transformTuple​(java.lang.Object[] tuple, java.lang.String[] aliases)
      Tuples are the elements making up each "row" of the query result.
      java.util.List untransformToTuples​(java.util.List results)
      Untransforms, if necessary, a List of values previously transformed by this (or an equivalent) CacheableResultTransformer.
      • Methods inherited from class java.lang.Object

        clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • create

        public static CacheableResultTransformer create​(ResultTransformer transformer,
                                                        java.lang.String[] aliases,
                                                        boolean[] includeInTuple)
        Returns a CacheableResultTransformer that is used to transform tuples to a value(s) that can be cached.
        Parameters:
        transformer - - result transformer that will ultimately be be used (after caching results)
        aliases - - the aliases that correspond to the tuple; if it is non-null, its length must equal the number of true elements in includeInTuple[]
        includeInTuple - - array with the i-th element indicating whether the i-th expression returned by a query is included in the tuple; the number of true values equals the length of the tuple that will be transformed; must be non-null
        Returns:
        a CacheableResultTransformer that is used to transform tuples to a value(s) that can be cached.
      • transformTuple

        public java.lang.Object transformTuple​(java.lang.Object[] tuple,
                                               java.lang.String[] aliases)
        Description copied from interface: ResultTransformer
        Tuples are the elements making up each "row" of the query result. The contract here is to transform these elements into the final row.
        Specified by:
        transformTuple in interface ResultTransformer
        Parameters:
        tuple - The result elements
        aliases - The result aliases ("parallel" array to tuple)
        Returns:
        The transformed row.
      • retransformResults

        public java.util.List retransformResults​(java.util.List transformedResults,
                                                 java.lang.String[] aliases,
                                                 ResultTransformer transformer,
                                                 boolean[] includeInTuple)
        Re-transforms, if necessary, a List of values previously transformed by this (or an equivalent) CacheableResultTransformer. Each element of the list is re-transformed in place (i.e, List elements are replaced with re-transformed values) and the original List is returned.

        If re-transformation is unnecessary, the original List is returned unchanged.

        Parameters:
        transformedResults - - results that were previously transformed
        aliases - - the aliases that correspond to the untransformed tuple;
        transformer - - the transformer for the re-transformation
        includeInTuple - indicates the indexes of
        Returns:
        transformedResults, with each element re-transformed (if nececessary)
      • untransformToTuples

        public java.util.List untransformToTuples​(java.util.List results)
        Untransforms, if necessary, a List of values previously transformed by this (or an equivalent) CacheableResultTransformer. Each element of the list is untransformed in place (i.e, List elements are replaced with untransformed values) and the original List is returned.

        If not unnecessary, the original List is returned unchanged.

        NOTE: If transformed values are a subset of the original tuple, then, on return, elements corresponding to excluded tuple elements will be null.

        Parameters:
        results - - results that were previously transformed
        Returns:
        results, with each element untransformed (if nececessary)
      • getCachedResultTypes

        public Type[] getCachedResultTypes​(Type[] tupleResultTypes)
      • transformList

        public java.util.List transformList​(java.util.List list)
        Description copied from interface: ResultTransformer
        Here we have an opportunity to perform transformation on the query result as a whole. This might be useful to convert from one collection type to another or to remove duplicates from the result, etc.
        Specified by:
        transformList in interface ResultTransformer
        Parameters:
        list - The result.
        Returns:
        The transformed result.
      • equals

        public boolean equals​(java.lang.Object o)
        Overrides:
        equals in class java.lang.Object
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class java.lang.Object