Class If<I,​O>

  • All Implemented Interfaces:
    Closeable, AutoCloseable, Input<I>, InputOutput<I,​O>, Output<O>, Operation, Operations<Operation>

    public class If<I,​O>
    extends GenericInput<I>
    implements InputOutput<I,​O>, Operations<Operation>

    A If is an Operation which will execute one of two Operations, based on the result of testing an input Object against a provided Predicate.

    This Predicate can also be configured with an Conditional, which simply wraps an Operation and a Predicate. This enables pre-predicate transformation of the input, which allows properties other than the input object to be passed to the predicate, whilst preserving the initial input.

    As an example, this allows you to build an Operation which extracts a property from the input, passes it to the predicate, then the untouched original input is passed on to the operation determined by the predicate test.

    A simple boolean, or anything that resolves to a boolean, can also be used to determine which Operation to execute.

    See Also:
    If.Builder
    • Constructor Detail

      • If

        public If()
    • Method Detail

      • getOutputTypeReference

        public com.fasterxml.jackson.core.type.TypeReference<O> getOutputTypeReference()
        Specified by:
        getOutputTypeReference in interface Output<I>
      • shallowClone

        public If<I,​O> shallowClone()
                                   throws org.apache.commons.lang3.exception.CloneFailedException
        Description copied from interface: Operation
        Operation implementations should ensure a ShallowClone method is implemented. Performs a shallow clone. Creates a new instance and copies the fields across. It does not clone the fields. If the operation contains nested operations, these must also be cloned.
        Specified by:
        shallowClone in interface Operation
        Returns:
        shallow clone
        Throws:
        org.apache.commons.lang3.exception.CloneFailedException - if a Clone error occurs
      • getOptions

        public Map<String,​String> getOptions()
        Specified by:
        getOptions in interface Operation
        Returns:
        the operation options. This may contain store specific options such as authorisation strings or and other properties required for the operation to be executed. Note these options will probably not be interpreted in the same way by every store implementation.
      • setOptions

        public void setOptions​(Map<String,​String> options)
        Specified by:
        setOptions in interface Operation
        Parameters:
        options - the operation options. This may contain store specific options such as authorisation strings or and other properties required for the operation to be executed. Note these options will probably not be interpreted in the same way by every store implementation.
      • updateOperations

        public void updateOperations​(Collection<Operation> operations)
        Description copied from interface: Operations
        Updates the operations using the provided collection. By default this will just clear the current operations collection and add all the new operations.
        Specified by:
        updateOperations in interface Operations<I>
        Parameters:
        operations - the new operations.
      • getCondition

        public Boolean getCondition()
      • setCondition

        public void setCondition​(Boolean condition)
      • setThen

        public void setThen​(Operation then)
      • getOtherwise

        public Operation getOtherwise()
      • setOtherwise

        public void setOtherwise​(Operation otherwise)
      • setConditional

        public void setConditional​(Conditional conditional)
      • hashCode

        public int hashCode()
        Overrides:
        hashCode in class Object