Class If<I,O>
- java.lang.Object
-
- uk.gov.gchq.gaffer.operation.io.GenericInput<I>
-
- uk.gov.gchq.gaffer.operation.impl.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
Ifis anOperationwhich will execute one of two Operations, based on the result of testing an input Object against a providedPredicate.This
Predicatecan also be configured with anConditional, which simply wraps anOperationand aPredicate. 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
Operationwhich 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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIf.Builder<I,O>-
Nested classes/interfaces inherited from class uk.gov.gchq.gaffer.operation.io.GenericInput
GenericInput.InputWrapper, GenericInput.InputWrapperNoTypeInfo, GenericInput.MultiInputWrapper
-
Nested classes/interfaces inherited from interface uk.gov.gchq.gaffer.operation.Operation
Operation.BaseBuilder<OP extends Operation,B extends Operation.BaseBuilder<OP,?>>
-
-
Constructor Summary
Constructors Constructor Description If()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanequals(Object obj)BooleangetCondition()ConditionalgetConditional()Collection<Operation>getOperations()Should return aCollectionof all operations contained within theOperationsimplementation.Map<String,String>getOptions()OperationgetOtherwise()com.fasterxml.jackson.core.type.TypeReference<O>getOutputTypeReference()OperationgetThen()inthashCode()voidsetCondition(Boolean condition)voidsetConditional(Conditional conditional)voidsetOptions(Map<String,String> options)voidsetOtherwise(Operation otherwise)voidsetThen(Operation then)If<I,O>shallowClone()Operation implementations should ensure a ShallowClone method is implemented.StringtoString()voidupdateOperations(Collection<Operation> operations)Updates the operations using the provided collection.-
Methods inherited from class uk.gov.gchq.gaffer.operation.io.GenericInput
getInput, setInput
-
Methods inherited from interface uk.gov.gchq.gaffer.operation.Operation
_getNullOrOptions, addOption, containsOption, getOption, getOption, validate, validateRequiredFieldPresent
-
Methods inherited from interface uk.gov.gchq.gaffer.operation.Operations
flatten, getOperationsClass
-
Methods inherited from interface uk.gov.gchq.gaffer.operation.io.Output
castToOutputType, getOutputClass, getOutputType
-
-
-
-
Method Detail
-
getOutputTypeReference
public com.fasterxml.jackson.core.type.TypeReference<O> getOutputTypeReference()
- Specified by:
getOutputTypeReferencein interfaceOutput<I>
-
shallowClone
public If<I,O> shallowClone() throws org.apache.commons.lang3.exception.CloneFailedException
Description copied from interface:OperationOperation 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:
shallowClonein interfaceOperation- Returns:
- shallow clone
- Throws:
org.apache.commons.lang3.exception.CloneFailedException- if a Clone error occurs
-
getOptions
public Map<String,String> getOptions()
- Specified by:
getOptionsin interfaceOperation- 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:
setOptionsin interfaceOperation- 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.
-
getOperations
public Collection<Operation> getOperations()
Description copied from interface:OperationsShould return aCollectionof all operations contained within theOperationsimplementation. The collection of operations may be modified by Gaffer.- Specified by:
getOperationsin interfaceOperations<I>- Returns:
- A
CollectionofOperations.
-
updateOperations
public void updateOperations(Collection<Operation> operations)
Description copied from interface:OperationsUpdates the operations using the provided collection. By default this will just clear the current operations collection and add all the new operations.- Specified by:
updateOperationsin interfaceOperations<I>- Parameters:
operations- the new operations.
-
getCondition
public Boolean getCondition()
-
setCondition
public void setCondition(Boolean condition)
-
getThen
public Operation getThen()
-
setThen
public void setThen(Operation then)
-
getOtherwise
public Operation getOtherwise()
-
setOtherwise
public void setOtherwise(Operation otherwise)
-
getConditional
public Conditional getConditional()
-
setConditional
public void setConditional(Conditional conditional)
-
-