Class ChainedExtractor<T,​E>

    • Constructor Detail

      • ChainedExtractor

        public ChainedExtractor()
        Default constructor (necessary for the ExternalizableLite interface).
      • ChainedExtractor

        public ChainedExtractor​(ValueExtractor[] aExtractor)
        Construct a ChainedExtractor based on a specified ValueExtractor array.
        Parameters:
        aExtractor - the ValueExtractor array
      • ChainedExtractor

        public ChainedExtractor​(ValueExtractor<? super T,​? extends U> extractor1,
                                ValueExtractor<? super U,​? extends E> extractor2)
        Construct a ChainedExtractor based on two extractors.
        Type Parameters:
        U - the type of value that will be extracted in the first ValueExtractor
        Parameters:
        extractor1 - the first ValueExtractor
        extractor2 - the second ValueExtractor
      • ChainedExtractor

        public ChainedExtractor​(String sName)
        Construct a ChainedExtractor for a specified method name sequence.
        Parameters:
        sName - a dot-delimited sequence of method names which results in a ChainedExtractor that is based on an array of corresponding ReflectionExtractor objects
    • Method Detail

      • ensureTarget

        public void ensureTarget()
        Ensure that this target is correct after first extractor manually updated.
      • extract

        public E extract​(Object oTarget)
        Extract the value from the passed object. The underlying extractors are applied sequentially, so a result of a previous extractor serves as a target object for a next one. A value of null prevents any further extractions and is returned immediately. For intrinsic types, the returned value is expected to be a standard wrapper type in the same manner that reflection works; for example, int would be returned as a java.lang.Integer.
        Specified by:
        extract in interface ValueExtractor<T,​E>
        Overrides:
        extract in class AbstractExtractor<T,​E>
        Parameters:
        oTarget - the object to extract the value from
        Returns:
        the extracted value; null is an acceptable value
      • extractFromEntry

        public E extractFromEntry​(Map.Entry entry)
        Extract the value from the passed entry. The underlying extractors are applied sequentially, so a result of a previous extractor serves as a target object for a next one. A value of null prevents any further extractions and is returned immediately. For intrinsic types, the returned value is expected to be a standard wrapper type in the same manner that reflection works; for example, int would be returned as a java.lang.Integer.
        Overrides:
        extractFromEntry in class AbstractExtractor<T,​E>
        Parameters:
        entry - an Entry object to extract a desired value from
        Returns:
        the extracted value
      • compose

        public <V> ValueExtractor<V,​E> compose​(ValueExtractor<? super V,​? extends T> before)
        Description copied from interface: ValueExtractor
        Returns a composed extractor that first applies the before extractor to its input, and then applies this extractor to the result. If evaluation of either extractor throws an exception, it is relayed to the caller of the composed extractor.
        Type Parameters:
        V - the type of input to the before extractor, and to the composed extractor
        Parameters:
        before - the extractor to apply before this extractor is applied
        Returns:
        a composed extractor that first applies the before extractor and then applies this extractor
        See Also:
        ValueExtractor.andThen(ValueExtractor)
      • andThen

        public <V> ValueExtractor<T,​V> andThen​(ValueExtractor<? super E,​? extends V> after)
        Description copied from interface: ValueExtractor
        Returns a composed extractor that first applies this extractor to its input, and then applies the after extractor to the result. If evaluation of either extractor throws an exception, it is relayed to the caller of the composed extractor.
        Type Parameters:
        V - the type of output of the after extractor, and of the composed extractor
        Parameters:
        after - the extractor to apply after this extractor is applied
        Returns:
        a composed extractor that first applies this extractor and then applies the after extractor
        See Also:
        ValueExtractor.compose(ValueExtractor)
      • createExtractors

        public static ValueExtractor[] createExtractors​(String sName)
        Parse a dot-delimited sequence of method names and instantiate a corresponding array of ReflectionExtractor objects.
        Parameters:
        sName - a dot-delimited sequence of method names
        Returns:
        an array of ReflectionExtractor objects
      • merge

        protected static ValueExtractor[] merge​(ValueExtractor[] aHead,
                                                ValueExtractor[] aTail)
        Return a ValueExtractor array with the provided arrays merged into a single array.
        Parameters:
        aHead - the first group of elements in the returned array
        aTail - the second group of elements in the returned array
        Returns:
        a ValueExtractor array with the provided arrays merged into a single array
      • computeTarget

        protected int computeTarget()
        Return the target of the first extractor in composite extractor.

        Enables equivalence between KeyExtractor("foo.bar") and ChainExtractor(ReflectionExtractor("foo", null, KEY), ReflectionExtractor("bar")).

        Returns:
        the target of the first extractor in CompositeExtractor.
        Since:
        12.2.1.4