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
If
is anOperation
which will execute one of two Operations, based on the result of testing an input Object against a providedPredicate
.This
Predicate
can also be configured with anConditional
, which simply wraps anOperation
and 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
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
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
If.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 boolean
equals(Object obj)
Boolean
getCondition()
Conditional
getConditional()
Collection<Operation>
getOperations()
Should return aCollection
of all operations contained within theOperations
implementation.Map<String,String>
getOptions()
Operation
getOtherwise()
com.fasterxml.jackson.core.type.TypeReference<O>
getOutputTypeReference()
Operation
getThen()
int
hashCode()
void
setCondition(Boolean condition)
void
setConditional(Conditional conditional)
void
setOptions(Map<String,String> options)
void
setOtherwise(Operation otherwise)
void
setThen(Operation then)
If<I,O>
shallowClone()
Operation implementations should ensure a ShallowClone method is implemented.String
toString()
void
updateOperations(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:
getOutputTypeReference
in interfaceOutput<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 interfaceOperation
- 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 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:
setOptions
in 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:Operations
Should return aCollection
of all operations contained within theOperations
implementation. The collection of operations may be modified by Gaffer.- Specified by:
getOperations
in interfaceOperations<I>
- Returns:
- A
Collection
ofOperation
s.
-
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 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)
-
-