org.op4j.operators.impl.fn.generic
Class Level0GenericUniqOperator<I,T>

Object
  extended by org.op4j.operators.impl.AbstractOperator
      extended by org.op4j.operators.impl.fn.generic.Level0GenericUniqOperator<I,T>
All Implemented Interfaces:
ILevel0GenericUniqOperator<I,T>, BuilderOperator<I,T>, CastableToStructuresOperator, CastableToTypeOperator<T>, ExecutableOperator<T>, Operator, ReplaceableIfNullOperator<T>, ReplaceableOperator<T>, SelectableOperator<T>, UniqFnOperator<I,T>, UniqOperator<T>

public final class Level0GenericUniqOperator<I,T>
extends AbstractOperator
implements UniqFnOperator<I,T>, ILevel0GenericUniqOperator<I,T>

Since:
1.0
Author:
Daniel Fernández

Constructor Summary
Level0GenericUniqOperator(Target target)
           
 
Method Summary
<X> Level0GenericUniqOperator<I,X>
castTo(org.javaruntype.type.Type<X> type)
           Casts the operator's target as the specified type.
<X> Level0ArrayOperator<I,X>
castToArrayOf(org.javaruntype.type.Type<X> type)
           Casts the operator's target as an array of the specified type.
<X> Level0ListOperator<I,X>
castToListOf(org.javaruntype.type.Type<X> type)
           Casts the operator's target as a list of the specified type.
<K,V> Level0MapOperator<I,K,V>
castToMapOf(org.javaruntype.type.Type<K> keyType, org.javaruntype.type.Type<V> valueType)
           Casts the operator's target as a map of the specified types.
<X> Level0SetOperator<I,X>
castToSetOf(org.javaruntype.type.Type<X> type)
           Casts the operator's target as a set of the specified type.
<X> Level0GenericUniqOperator<I,X>
exec(IFunction<? super T,X> function)
           Executes the specified function on the target object, creating a new operator containing the result of the execution.
 Level0GenericUniqOperator<I,T> execIfFalse(IFunction<? super T,Boolean> eval, IFunction<? super T,? extends T> function)
           Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
<X> Level0GenericUniqOperator<I,X>
execIfFalse(IFunction<? super T,Boolean> eval, IFunction<? super T,X> function, IFunction<? super T,X> elseFunction)
           Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
 Level0GenericUniqOperator<I,T> execIfNotNull(IFunction<? super T,? extends T> function)
           Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
<X> Level0GenericUniqOperator<I,X>
execIfNotNull(IFunction<? super T,X> function, IFunction<? super T,X> elseFunction)
           Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
 Level0GenericUniqOperator<I,T> execIfNull(IFunction<? super T,? extends T> function)
           Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
<X> Level0GenericUniqOperator<I,X>
execIfNull(IFunction<? super T,X> function, IFunction<? super T,X> elseFunction)
           Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
 Level0GenericUniqOperator<I,T> execIfTrue(IFunction<? super T,Boolean> eval, IFunction<? super T,? extends T> function)
           Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
<X> Level0GenericUniqOperator<I,X>
execIfTrue(IFunction<? super T,Boolean> eval, IFunction<? super T,X> function, IFunction<? super T,X> elseFunction)
           Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
 Function<I,T> get()
           Returns a function which will execute all the logic specified from the "Fn.on" expression.
 Level0GenericUniqSelectedOperator<I,T> ifFalse(IFunction<? super T,Boolean> eval)
           Selects only those targets for which the specified evaluator returns false.
 Level0GenericUniqSelectedOperator<I,T> ifNotNull()
           Selects only those targets which are not null.
 Level0GenericUniqSelectedOperator<I,T> ifNull()
           Selects only those targets which are null.
 Level0GenericUniqSelectedOperator<I,T> ifTrue(IFunction<? super T,Boolean> eval)
           Selects only those targets for which the specified evaluator returns true.
 Level0ArrayOperator<I,T> intoSingletonArrayOf(org.javaruntype.type.Type<T> type)
           Builds an array of the specified type containing the operator's targets.
 Level0ListOperator<I,T> intoSingletonList()
           Builds a list containing the operator's targets.
<K,V> Level0MapOperator<I,K,V>
intoSingletonMap(IFunction<? super T,Map.Entry<K,V>> mapBuilder)
           Builds a map by inputting the operator's targets into a map builder object (a function returning map entries), which is in charge of creating the corresponding key and value for each original target.
 Level0SetOperator<I,T> intoSingletonSet()
           Builds a set containing the operator's targets.
 Level0GenericUniqOperator<I,T> replaceIfNullWith(T replacement)
           Replaces the current target object with the specified replacement if the current target is null.
 Level0GenericUniqOperator<I,T> replaceWith(T replacement)
           Replaces the current target object with the specified replacement.
<K> Level0MapOperator<I,K,T>
zipKey(K key)
           Builds a one-entry map using the operator's target as a value, and the specified object as a key.
<K> Level0MapOperator<I,K,T>
zipKeyBy(IFunction<? super T,K> keyEval)
           Builds a one-entry map using the operator's target as a value, and the result of executing the keyEval evaluator on the target as a key.
<V> Level0MapOperator<I,T,V>
zipValue(V value)
           Builds a one-entry map using the operator's target as a key, and the specified object as a value.
<V> Level0MapOperator<I,T,V>
zipValueBy(IFunction<? super T,V> valueEval)
           Builds a one-entry map using the operator's target as a key, and the result of executing the valueEval evaluator on the target as a value.
 
Methods inherited from class org.op4j.operators.impl.AbstractOperator
getTarget
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Level0GenericUniqOperator

public Level0GenericUniqOperator(Target target)
Method Detail

intoSingletonArrayOf

public Level0ArrayOperator<I,T> intoSingletonArrayOf(org.javaruntype.type.Type<T> type)
Description copied from interface: BuilderOperator

Builds an array of the specified type containing the operator's targets.

Specified by:
intoSingletonArrayOf in interface ILevel0GenericUniqOperator<I,T>
Specified by:
intoSingletonArrayOf in interface BuilderOperator<I,T>
Parameters:
type - the type if which the array will be instantiated
Returns:
an operator on the resulting array

intoSingletonList

public Level0ListOperator<I,T> intoSingletonList()
Description copied from interface: BuilderOperator

Builds a list containing the operator's targets.

Specified by:
intoSingletonList in interface ILevel0GenericUniqOperator<I,T>
Specified by:
intoSingletonList in interface BuilderOperator<I,T>
Returns:
an operator on the resulting list

zipKeyBy

public <K> Level0MapOperator<I,K,T> zipKeyBy(IFunction<? super T,K> keyEval)
Description copied from interface: BuilderOperator

Builds a one-entry map using the operator's target as a value, and the result of executing the keyEval evaluator on the target as a key.

Specified by:
zipKeyBy in interface ILevel0GenericUniqOperator<I,T>
Specified by:
zipKeyBy in interface BuilderOperator<I,T>
Type Parameters:
K - the type of the new key, resulting from evaluating keyEval
Parameters:
keyEval - the evaluator to be used for obtaining the key
Returns:
an operator on the resulting map

zipValueBy

public <V> Level0MapOperator<I,T,V> zipValueBy(IFunction<? super T,V> valueEval)
Description copied from interface: BuilderOperator

Builds a one-entry map using the operator's target as a key, and the result of executing the valueEval evaluator on the target as a value.

Specified by:
zipValueBy in interface ILevel0GenericUniqOperator<I,T>
Specified by:
zipValueBy in interface BuilderOperator<I,T>
Type Parameters:
V - the type of the new value, resulting from evaluating valueEval
Parameters:
valueEval - the evaluator to be used for obtaining the value
Returns:
an operator on the resulting map

zipKey

public <K> Level0MapOperator<I,K,T> zipKey(K key)
Description copied from interface: BuilderOperator

Builds a one-entry map using the operator's target as a value, and the specified object as a key.

Specified by:
zipKey in interface ILevel0GenericUniqOperator<I,T>
Specified by:
zipKey in interface BuilderOperator<I,T>
Type Parameters:
K - the type of the new key, resulting from evaluating keyEval
Parameters:
key - the key to be zipped
Returns:
an operator on the resulting map

zipValue

public <V> Level0MapOperator<I,T,V> zipValue(V value)
Description copied from interface: BuilderOperator

Builds a one-entry map using the operator's target as a key, and the specified object as a value.

Specified by:
zipValue in interface ILevel0GenericUniqOperator<I,T>
Specified by:
zipValue in interface BuilderOperator<I,T>
Type Parameters:
V - the type of the new value, resulting from evaluating valueEval
Parameters:
value - the value to be zipped
Returns:
an operator on the resulting map

intoSingletonMap

public <K,V> Level0MapOperator<I,K,V> intoSingletonMap(IFunction<? super T,Map.Entry<K,V>> mapBuilder)
Description copied from interface: BuilderOperator

Builds a map by inputting the operator's targets into a map builder object (a function returning map entries), which is in charge of creating the corresponding key and value for each original target. If two values have the same key, all of them but the last to be evaluated will be overwritten.

Specified by:
intoSingletonMap in interface ILevel0GenericUniqOperator<I,T>
Specified by:
intoSingletonMap in interface BuilderOperator<I,T>
Type Parameters:
K - the type of the keys returned by the map builder
V - the type of the values returned by the map builder
Parameters:
mapBuilder - the map builder function
Returns:
an operator on the resulting map

intoSingletonSet

public Level0SetOperator<I,T> intoSingletonSet()
Description copied from interface: BuilderOperator

Builds a set containing the operator's targets.

Specified by:
intoSingletonSet in interface ILevel0GenericUniqOperator<I,T>
Specified by:
intoSingletonSet in interface BuilderOperator<I,T>
Returns:
an operator on the resulting set

castToArrayOf

public <X> Level0ArrayOperator<I,X> castToArrayOf(org.javaruntype.type.Type<X> type)
Description copied from interface: CastableToStructuresOperator

Casts the operator's target as an array of the specified type.

Specified by:
castToArrayOf in interface ILevel0GenericUniqOperator<I,T>
Specified by:
castToArrayOf in interface CastableToStructuresOperator
Type Parameters:
X - the type of the elements of the array
Parameters:
type - the type of the elements of the array
Returns:
the resulting casted operator

castToListOf

public <X> Level0ListOperator<I,X> castToListOf(org.javaruntype.type.Type<X> type)
Description copied from interface: CastableToStructuresOperator

Casts the operator's target as a list of the specified type.

Specified by:
castToListOf in interface ILevel0GenericUniqOperator<I,T>
Specified by:
castToListOf in interface CastableToStructuresOperator
Type Parameters:
X - the type of the elements of the list
Parameters:
type - the type of the elements of the list
Returns:
the resulting casted operator

castToMapOf

public <K,V> Level0MapOperator<I,K,V> castToMapOf(org.javaruntype.type.Type<K> keyType,
                                                  org.javaruntype.type.Type<V> valueType)
Description copied from interface: CastableToStructuresOperator

Casts the operator's target as a map of the specified types.

Specified by:
castToMapOf in interface ILevel0GenericUniqOperator<I,T>
Specified by:
castToMapOf in interface CastableToStructuresOperator
Type Parameters:
K - the type for the map's keys
V - the type for the map's values
Parameters:
keyType - the type for the map's keys
valueType - the type for the map's values
Returns:
the resulting map

castToSetOf

public <X> Level0SetOperator<I,X> castToSetOf(org.javaruntype.type.Type<X> type)
Description copied from interface: CastableToStructuresOperator

Casts the operator's target as a set of the specified type.

Specified by:
castToSetOf in interface ILevel0GenericUniqOperator<I,T>
Specified by:
castToSetOf in interface CastableToStructuresOperator
Type Parameters:
X - the type of the elements of the set
Parameters:
type - the type of the elements of the set
Returns:
the resulting casted operator

castTo

public <X> Level0GenericUniqOperator<I,X> castTo(org.javaruntype.type.Type<X> type)
Description copied from interface: CastableToTypeOperator

Casts the operator's target as the specified type.

Specified by:
castTo in interface ILevel0GenericUniqOperator<I,T>
Specified by:
castTo in interface CastableToTypeOperator<T>
Type Parameters:
X - the type of the targets
Parameters:
type - the type of targets
Returns:
the resulting casted operator

get

public Function<I,T> get()
Description copied from interface: UniqFnOperator

Returns a function which will execute all the logic specified from the "Fn.on" expression.

Specified by:
get in interface UniqFnOperator<I,T>
Returns:
the function.

ifTrue

public Level0GenericUniqSelectedOperator<I,T> ifTrue(IFunction<? super T,Boolean> eval)
Description copied from interface: SelectableOperator

Selects only those targets for which the specified evaluator returns true. After this method, all the subsequently executed operations will only be executed on the target objects selected here, until an "endIf()" method is called.

Specified by:
ifTrue in interface ILevel0GenericUniqOperator<I,T>
Specified by:
ifTrue in interface SelectableOperator<T>
Parameters:
eval - the evaluator to be used for selecting targets.
Returns:
an operator which will execute all subsequent operations only on the selected target objects.

ifFalse

public Level0GenericUniqSelectedOperator<I,T> ifFalse(IFunction<? super T,Boolean> eval)
Description copied from interface: SelectableOperator

Selects only those targets for which the specified evaluator returns false. After this method, all the subsequently executed operations will only be executed on the target objects selected here, until an "endIf()" method is called.

Specified by:
ifFalse in interface ILevel0GenericUniqOperator<I,T>
Specified by:
ifFalse in interface SelectableOperator<T>
Parameters:
eval - the evaluator to be used for selecting targets.
Returns:
an operator which will execute all subsequent operations only on the selected target objects.

ifNotNull

public Level0GenericUniqSelectedOperator<I,T> ifNotNull()
Description copied from interface: SelectableOperator

Selects only those targets which are not null. After this method, all the subsequently executed operations will only be executed on the target objects selected here, until an "endIf()" method is called.

Specified by:
ifNotNull in interface ILevel0GenericUniqOperator<I,T>
Specified by:
ifNotNull in interface SelectableOperator<T>
Returns:
an operator which will execute all subsequent operations only on the selected target objects.

ifNull

public Level0GenericUniqSelectedOperator<I,T> ifNull()
Description copied from interface: SelectableOperator

Selects only those targets which are null. After this method, all the subsequently executed operations will only be executed on the target objects selected here, until an "endIf()" method is called.

Specified by:
ifNull in interface ILevel0GenericUniqOperator<I,T>
Specified by:
ifNull in interface SelectableOperator<T>
Returns:
an operator which will execute all subsequent operations only on the selected target objects.

exec

public <X> Level0GenericUniqOperator<I,X> exec(IFunction<? super T,X> function)
Description copied from interface: ExecutableOperator

Executes the specified function on the target object, creating a new operator containing the result of the execution.

This function must be able to take as input an object of type T (the current operator's target type) and will return an object of type X, which will be from then on the new operator's target type.

Specified by:
exec in interface ILevel0GenericUniqOperator<I,T>
Specified by:
exec in interface ExecutableOperator<T>
Type Parameters:
X - the type of the result, and new type for the operator
Parameters:
function - the function to be executed
Returns:
an operator on the results of function execution

replaceWith

public Level0GenericUniqOperator<I,T> replaceWith(T replacement)
Description copied from interface: ReplaceableOperator

Replaces the current target object with the specified replacement.

Specified by:
replaceWith in interface ILevel0GenericUniqOperator<I,T>
Specified by:
replaceWith in interface ReplaceableOperator<T>
Parameters:
replacement - the object which will replace the current target object.
Returns:
an operator containing the replacement object as target.

replaceIfNullWith

public Level0GenericUniqOperator<I,T> replaceIfNullWith(T replacement)
Description copied from interface: ReplaceableIfNullOperator

Replaces the current target object with the specified replacement if the current target is null.

Specified by:
replaceIfNullWith in interface ILevel0GenericUniqOperator<I,T>
Specified by:
replaceIfNullWith in interface ReplaceableIfNullOperator<T>
Parameters:
replacement - the object which will replace the current target object if target is null.
Returns:
an operator containing the original target object if it was not null, or the new one if null.

execIfFalse

public Level0GenericUniqOperator<I,T> execIfFalse(IFunction<? super T,Boolean> eval,
                                                  IFunction<? super T,? extends T> function)
Description copied from interface: ExecutableOperator

Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.

Specified by:
execIfFalse in interface ILevel0GenericUniqOperator<I,T>
Specified by:
execIfFalse in interface ExecutableOperator<T>
Parameters:
eval - the evaluation function used to select elements
function - the function to be executed on the selected elements
Returns:
an operator on the results of function execution

execIfFalse

public <X> Level0GenericUniqOperator<I,X> execIfFalse(IFunction<? super T,Boolean> eval,
                                                      IFunction<? super T,X> function,
                                                      IFunction<? super T,X> elseFunction)
Description copied from interface: ExecutableOperator

Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.

Specified by:
execIfFalse in interface ILevel0GenericUniqOperator<I,T>
Specified by:
execIfFalse in interface ExecutableOperator<T>
Type Parameters:
X - the new type returned by the functions
Parameters:
eval - the evaluation function used to select elements
function - the function to be executed on the selected elements
elseFunction - the function to be executed on the non-selected elements
Returns:
an operator on the results of function execution

execIfNotNull

public Level0GenericUniqOperator<I,T> execIfNotNull(IFunction<? super T,? extends T> function)
Description copied from interface: ExecutableOperator

Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.

Specified by:
execIfNotNull in interface ILevel0GenericUniqOperator<I,T>
Specified by:
execIfNotNull in interface ExecutableOperator<T>
Parameters:
function - the function to be executed on the selected elements
Returns:
an operator on the results of function execution

execIfNotNull

public <X> Level0GenericUniqOperator<I,X> execIfNotNull(IFunction<? super T,X> function,
                                                        IFunction<? super T,X> elseFunction)
Description copied from interface: ExecutableOperator

Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.

Specified by:
execIfNotNull in interface ILevel0GenericUniqOperator<I,T>
Specified by:
execIfNotNull in interface ExecutableOperator<T>
Type Parameters:
X - the new type returned by the functions
Parameters:
function - the function to be executed on the selected elements
elseFunction - the function to be executed on the non-selected elements
Returns:
an operator on the results of function execution

execIfNull

public Level0GenericUniqOperator<I,T> execIfNull(IFunction<? super T,? extends T> function)
Description copied from interface: ExecutableOperator

Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.

Specified by:
execIfNull in interface ILevel0GenericUniqOperator<I,T>
Specified by:
execIfNull in interface ExecutableOperator<T>
Parameters:
function - the function to be executed on the selected elements
Returns:
an operator on the results of function execution

execIfNull

public <X> Level0GenericUniqOperator<I,X> execIfNull(IFunction<? super T,X> function,
                                                     IFunction<? super T,X> elseFunction)
Description copied from interface: ExecutableOperator

Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.

Specified by:
execIfNull in interface ILevel0GenericUniqOperator<I,T>
Specified by:
execIfNull in interface ExecutableOperator<T>
Type Parameters:
X - the new type returned by the functions
Parameters:
function - the function to be executed on the selected elements
elseFunction - the function to be executed on the non-selected elements
Returns:
an operator on the results of function execution

execIfTrue

public Level0GenericUniqOperator<I,T> execIfTrue(IFunction<? super T,Boolean> eval,
                                                 IFunction<? super T,? extends T> function)
Description copied from interface: ExecutableOperator

Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.

Specified by:
execIfTrue in interface ILevel0GenericUniqOperator<I,T>
Specified by:
execIfTrue in interface ExecutableOperator<T>
Parameters:
eval - the evaluation function used to select elements
function - the function to be executed on the selected elements
Returns:
an operator on the results of function execution

execIfTrue

public <X> Level0GenericUniqOperator<I,X> execIfTrue(IFunction<? super T,Boolean> eval,
                                                     IFunction<? super T,X> function,
                                                     IFunction<? super T,X> elseFunction)
Description copied from interface: ExecutableOperator

Executes a function in a way equivalent to ExecutableOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.

Specified by:
execIfTrue in interface ILevel0GenericUniqOperator<I,T>
Specified by:
execIfTrue in interface ExecutableOperator<T>
Type Parameters:
X - the new type returned by the functions
Parameters:
eval - the evaluation function used to select elements
function - the function to be executed on the selected elements
elseFunction - the function to be executed on the non-selected elements
Returns:
an operator on the results of function execution


Copyright © 2012 The OP4J team. All Rights Reserved.