org.op4j.operators.impl.fn.array
Class Level1ArrayElementsOperator<I,T>

Object
  extended by org.op4j.operators.impl.AbstractOperator
      extended by org.op4j.operators.impl.fn.array.Level1ArrayElementsOperator<I,T>
All Implemented Interfaces:
ILevel1ArrayElementsOperator<I,T>, CastableToTypeOperator<T>, ExecutableArrayElementsOperator<T>, NavigatingCollectionOperator<T>, Operator, ReplaceableIfNullOperator<T>, ReplaceableOperator<T>, SelectableElementsOperator<T>, UniqFnOperator<I,T[]>, UniqOperator<T[]>

public final class Level1ArrayElementsOperator<I,T>
extends AbstractOperator
implements UniqFnOperator<I,T[]>, ILevel1ArrayElementsOperator<I,T>

Since:
1.0
Author:
Daniel Fernández

Constructor Summary
Level1ArrayElementsOperator(org.javaruntype.type.Type<T> type, Target target)
           
 
Method Summary
<X> Level1ArrayElementsOperator<I,X>
castTo(org.javaruntype.type.Type<X> elementType)
           Casts the operator's target as the specified type.
 Level0ArrayOperator<I,T> endFor()
           Ends the current iteration.
 Level1ArrayElementsOperator<I,T> exec(IFunction<? super T,? extends T> function)
           Executes the specified function on the target object, creating a new operator containing the result of the execution as a new array.
<X> Level1ArrayElementsOperator<I,X>
exec(org.javaruntype.type.Type<X> newType, IFunction<? super T,X> function)
           Executes the specified function on the target object, creating a new array containing the result of the execution.
 Level1ArrayElementsOperator<I,T> execIfFalse(IFunction<? super T,Boolean> eval, IFunction<? super T,? extends T> function)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
<X> Level1ArrayElementsOperator<I,X>
execIfFalse(org.javaruntype.type.Type<X> newType, IFunction<? super T,Boolean> eval, IFunction<? super T,X> function, IFunction<? super T,X> elseFunction)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
 Level1ArrayElementsOperator<I,T> execIfIndex(int[] indexes, IFunction<? super T,? extends T> function)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
<X> Level1ArrayElementsOperator<I,X>
execIfIndex(org.javaruntype.type.Type<X> newType, int[] indexes, IFunction<? super T,X> function, IFunction<? super T,X> elseFunction)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
 Level1ArrayElementsOperator<I,T> execIfIndexNot(int[] indexes, IFunction<? super T,? extends T> function)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
<X> Level1ArrayElementsOperator<I,X>
execIfIndexNot(org.javaruntype.type.Type<X> newType, int[] indexes, IFunction<? super T,X> function, IFunction<? super T,X> elseFunction)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
 Level1ArrayElementsOperator<I,T> execIfNotNull(IFunction<? super T,? extends T> function)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
<X> Level1ArrayElementsOperator<I,X>
execIfNotNull(org.javaruntype.type.Type<X> newType, IFunction<? super T,X> function, IFunction<? super T,X> elseFunction)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
 Level1ArrayElementsOperator<I,T> execIfNull(IFunction<? super T,? extends T> function)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
<X> Level1ArrayElementsOperator<I,X>
execIfNull(org.javaruntype.type.Type<X> newType, IFunction<? super T,X> function, IFunction<? super T,X> elseFunction)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
 Level1ArrayElementsOperator<I,T> execIfTrue(IFunction<? super T,Boolean> eval, IFunction<? super T,? extends T> function)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.exec(IFunction) but only on selected elements, leaving all other elements untouched.
<X> Level1ArrayElementsOperator<I,X>
execIfTrue(org.javaruntype.type.Type<X> newType, IFunction<? super T,Boolean> eval, IFunction<? super T,X> function, IFunction<? super T,X> elseFunction)
           Executes a function in a way equivalent to ExecutableArrayElementsOperator.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.
 Level1ArrayElementsSelectedOperator<I,T> ifFalse(IFunction<? super T,Boolean> eval)
           Selects only those targets for which the specified evaluator returns false.
 Level1ArrayElementsSelectedOperator<I,T> ifIndex(int... indexes)
           Selects only those targets which index in the current level of iteration matches any of the specified indexes.
 Level1ArrayElementsSelectedOperator<I,T> ifIndexNot(int... indexes)
           Selects only those targets which index in the current level of iteration does not match any of the specified indexes.
 Level1ArrayElementsSelectedOperator<I,T> ifNotNull()
           Selects only those targets which are not null.
 Level1ArrayElementsSelectedOperator<I,T> ifNull()
           Selects only those targets which are null.
 Level1ArrayElementsSelectedOperator<I,T> ifTrue(IFunction<? super T,Boolean> eval)
           Selects only those targets for which the specified evaluator returns true.
 Level1ArrayElementsOperator<I,T> replaceIfNullWith(T replacement)
           Replaces the current target object with the specified replacement if the current target is null.
 Level1ArrayElementsOperator<I,T> replaceWith(T replacement)
           Replaces the current target object with the specified replacement.
 
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

Level1ArrayElementsOperator

public Level1ArrayElementsOperator(org.javaruntype.type.Type<T> type,
                                   Target target)
Method Detail

endFor

public Level0ArrayOperator<I,T> endFor()
Description copied from interface: NavigatingCollectionOperator

Ends the current iteration. After the execution of this method, all subsequent operations will be applied on the iterated collection as a whole instead of in a by-element basis.

Specified by:
endFor in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
endFor in interface NavigatingCollectionOperator<T>
Returns:
an operator which will execute all operations on the iterated collection as a whole.

castTo

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

Casts the operator's target as the specified type.

Specified by:
castTo in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
castTo in interface CastableToTypeOperator<T>
Type Parameters:
X - the type of the targets
Parameters:
elementType - 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.

ifIndex

public Level1ArrayElementsSelectedOperator<I,T> ifIndex(int... indexes)
Description copied from interface: SelectableElementsOperator

Selects only those targets which index in the current level of iteration matches any of the specified indexes. 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:
ifIndex in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
ifIndex in interface SelectableElementsOperator<T>
Parameters:
indexes - the indexes of the target objects which will be selected.
Returns:
an operator which will execute all subsequent operations only on the selected target objects.

ifIndexNot

public Level1ArrayElementsSelectedOperator<I,T> ifIndexNot(int... indexes)
Description copied from interface: SelectableElementsOperator

Selects only those targets which index in the current level of iteration does not match any of the specified indexes. 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:
ifIndexNot in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
ifIndexNot in interface SelectableElementsOperator<T>
Parameters:
indexes - the indexes of the target objects which will be selected.
Returns:
an operator which will execute all subsequent operations only on the selected target objects.

ifTrue

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

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 ILevel1ArrayElementsOperator<I,T>
Specified by:
ifTrue in interface SelectableElementsOperator<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 Level1ArrayElementsSelectedOperator<I,T> ifFalse(IFunction<? super T,Boolean> eval)
Description copied from interface: SelectableElementsOperator

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 ILevel1ArrayElementsOperator<I,T>
Specified by:
ifFalse in interface SelectableElementsOperator<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 Level1ArrayElementsSelectedOperator<I,T> ifNotNull()
Description copied from interface: SelectableElementsOperator

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 ILevel1ArrayElementsOperator<I,T>
Specified by:
ifNotNull in interface SelectableElementsOperator<T>
Returns:
an operator which will execute all subsequent operations only on the selected target objects.

ifNull

public Level1ArrayElementsSelectedOperator<I,T> ifNull()
Description copied from interface: SelectableElementsOperator

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 ILevel1ArrayElementsOperator<I,T>
Specified by:
ifNull in interface SelectableElementsOperator<T>
Returns:
an operator which will execute all subsequent operations only on the selected target objects.

exec

public Level1ArrayElementsOperator<I,T> exec(IFunction<? super T,? extends T> function)
Description copied from interface: ExecutableArrayElementsOperator

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

This function must be able to take as input an object of type T (the current operator's target type) and will return another object of type T.

Specified by:
exec in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
exec in interface ExecutableArrayElementsOperator<T>
Parameters:
function - the function to be executed
Returns:
an operator on the results of function execution

exec

public <X> Level1ArrayElementsOperator<I,X> exec(org.javaruntype.type.Type<X> newType,
                                                 IFunction<? super T,X> function)
Description copied from interface: ExecutableArrayElementsOperator

Executes the specified function on the target object, creating a new array 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 ILevel1ArrayElementsOperator<I,T>
Specified by:
exec in interface ExecutableArrayElementsOperator<T>
Type Parameters:
X - the type of the result, and new type for the operator
Parameters:
newType - the type returned by the function
function - the function to be executed
Returns:
an operator on the results of function execution

replaceWith

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

Replaces the current target object with the specified replacement.

Specified by:
replaceWith in interface ILevel1ArrayElementsOperator<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 Level1ArrayElementsOperator<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 ILevel1ArrayElementsOperator<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 Level1ArrayElementsOperator<I,T> execIfFalse(IFunction<? super T,Boolean> eval,
                                                    IFunction<? super T,? extends T> function)
Description copied from interface: ExecutableArrayElementsOperator

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

Specified by:
execIfFalse in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
execIfFalse in interface ExecutableArrayElementsOperator<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> Level1ArrayElementsOperator<I,X> execIfFalse(org.javaruntype.type.Type<X> newType,
                                                        IFunction<? super T,Boolean> eval,
                                                        IFunction<? super T,X> function,
                                                        IFunction<? super T,X> elseFunction)
Description copied from interface: ExecutableArrayElementsOperator

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

Specified by:
execIfFalse in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
execIfFalse in interface ExecutableArrayElementsOperator<T>
Type Parameters:
X - the new type returned by the functions
Parameters:
newType - the new type returned by the functions
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

execIfIndex

public Level1ArrayElementsOperator<I,T> execIfIndex(int[] indexes,
                                                    IFunction<? super T,? extends T> function)
Description copied from interface: ExecutableArrayElementsOperator

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

Specified by:
execIfIndex in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
execIfIndex in interface ExecutableArrayElementsOperator<T>
Parameters:
indexes - the iteration indexes that will be selected
function - the function to be executed on the selected elements
Returns:
an operator on the results of function execution

execIfIndex

public <X> Level1ArrayElementsOperator<I,X> execIfIndex(org.javaruntype.type.Type<X> newType,
                                                        int[] indexes,
                                                        IFunction<? super T,X> function,
                                                        IFunction<? super T,X> elseFunction)
Description copied from interface: ExecutableArrayElementsOperator

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

Specified by:
execIfIndex in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
execIfIndex in interface ExecutableArrayElementsOperator<T>
Type Parameters:
X - the new type returned by the functions
Parameters:
newType - the new type returned by the functions
indexes - the iteration indexes that will be selected
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

execIfIndexNot

public Level1ArrayElementsOperator<I,T> execIfIndexNot(int[] indexes,
                                                       IFunction<? super T,? extends T> function)
Description copied from interface: ExecutableArrayElementsOperator

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

Specified by:
execIfIndexNot in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
execIfIndexNot in interface ExecutableArrayElementsOperator<T>
Parameters:
indexes - the iteration indexes that will not be selected
function - the function to be executed on the selected elements
Returns:
an operator on the results of function execution

execIfIndexNot

public <X> Level1ArrayElementsOperator<I,X> execIfIndexNot(org.javaruntype.type.Type<X> newType,
                                                           int[] indexes,
                                                           IFunction<? super T,X> function,
                                                           IFunction<? super T,X> elseFunction)
Description copied from interface: ExecutableArrayElementsOperator

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

Specified by:
execIfIndexNot in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
execIfIndexNot in interface ExecutableArrayElementsOperator<T>
Type Parameters:
X - the new type returned by the functions
Parameters:
newType - the new type returned by the functions
indexes - the iteration indexes that will not be selected
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 Level1ArrayElementsOperator<I,T> execIfNotNull(IFunction<? super T,? extends T> function)
Description copied from interface: ExecutableArrayElementsOperator

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

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

execIfNotNull

public <X> Level1ArrayElementsOperator<I,X> execIfNotNull(org.javaruntype.type.Type<X> newType,
                                                          IFunction<? super T,X> function,
                                                          IFunction<? super T,X> elseFunction)
Description copied from interface: ExecutableArrayElementsOperator

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

Specified by:
execIfNotNull in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
execIfNotNull in interface ExecutableArrayElementsOperator<T>
Type Parameters:
X - the new type returned by the functions
Parameters:
newType - the new type returned by the functions
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 Level1ArrayElementsOperator<I,T> execIfNull(IFunction<? super T,? extends T> function)
Description copied from interface: ExecutableArrayElementsOperator

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

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

execIfNull

public <X> Level1ArrayElementsOperator<I,X> execIfNull(org.javaruntype.type.Type<X> newType,
                                                       IFunction<? super T,X> function,
                                                       IFunction<? super T,X> elseFunction)
Description copied from interface: ExecutableArrayElementsOperator

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

Specified by:
execIfNull in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
execIfNull in interface ExecutableArrayElementsOperator<T>
Type Parameters:
X - the new type returned by the functions
Parameters:
newType - the new type returned by the functions
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 Level1ArrayElementsOperator<I,T> execIfTrue(IFunction<? super T,Boolean> eval,
                                                   IFunction<? super T,? extends T> function)
Description copied from interface: ExecutableArrayElementsOperator

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

Specified by:
execIfTrue in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
execIfTrue in interface ExecutableArrayElementsOperator<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> Level1ArrayElementsOperator<I,X> execIfTrue(org.javaruntype.type.Type<X> newType,
                                                       IFunction<? super T,Boolean> eval,
                                                       IFunction<? super T,X> function,
                                                       IFunction<? super T,X> elseFunction)
Description copied from interface: ExecutableArrayElementsOperator

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

Specified by:
execIfTrue in interface ILevel1ArrayElementsOperator<I,T>
Specified by:
execIfTrue in interface ExecutableArrayElementsOperator<T>
Type Parameters:
X - the new type returned by the functions
Parameters:
newType - the new type returned by the functions
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.