org.op4j.operators.impl.op.map
Class Level1MapEntriesOperator<I,K,V>

Object
  extended by org.op4j.operators.impl.AbstractOperator
      extended by org.op4j.operators.impl.op.map.Level1MapEntriesOperator<I,K,V>
All Implemented Interfaces:
ILevel1MapEntriesOperator<I,K,V>, ExecutableMapEntryOperator<K,V>, NavigableMapEntryOperator, NavigatingMapOperator<K,V>, Operator, ReplaceableOperator<Map.Entry<K,V>>, SelectableMapEntryOperator<K,V>, UniqOperator<Map<K,V>>, UniqOpOperator<I,Map<K,V>>

public final class Level1MapEntriesOperator<I,K,V>
extends AbstractOperator
implements UniqOpOperator<I,Map<K,V>>, ILevel1MapEntriesOperator<I,K,V>

Since:
1.0
Author:
Daniel Fernández

Constructor Summary
Level1MapEntriesOperator(Target target)
           
 
Method Summary
 Level0MapOperator<I,K,V> endFor()
           Ends the current iteration.
<X> Level1ListElementsOperator<I,X>
exec(IFunction<? super Map.Entry<K,V>,X> function)
           Executes the specified function on the target map entry, creating a new generic operator containing the result of the execution and setting the new operator type to the one specified.
<X,Y> Level1MapEntriesOperator<I,X,Y>
execAsMapEntry(IFunction<? super Map.Entry<K,V>,? extends Map.Entry<X,Y>> function)
           Executes the specified function on the target object, creating a new map entry operator containing the result of the execution.
 Level1MapEntriesOperator<I,K,V> execIfFalseAsMapEntry(IFunction<? super Map.Entry<K,V>,Boolean> eval, IFunction<? super Map.Entry<K,V>,? extends Map.Entry<? extends K,? extends V>> function)
           Executes a function in a way equivalent to ExecutableMapEntryOperator.execAsMapEntry(IFunction) but only on selected elements, leaving all other elements untouched.
<X,Y> Level1MapEntriesOperator<I,X,Y>
execIfFalseAsMapEntry(IFunction<? super Map.Entry<K,V>,Boolean> eval, IFunction<? super Map.Entry<K,V>,? extends Map.Entry<X,Y>> function, IFunction<? super Map.Entry<K,V>,? extends Map.Entry<X,Y>> elseFunction)
           Executes a function in a way equivalent to ExecutableMapEntryOperator.execAsMapEntry(IFunction) but only on selected elements, leaving all other elements untouched.
 Level1MapEntriesOperator<I,K,V> execIfTrueAsMapEntry(IFunction<? super Map.Entry<K,V>,Boolean> eval, IFunction<? super Map.Entry<K,V>,? extends Map.Entry<? extends K,? extends V>> function)
           Executes a function in a way equivalent to ExecutableMapEntryOperator.execAsMapEntry(IFunction) but only on selected elements, leaving all other elements untouched.
<X,Y> Level1MapEntriesOperator<I,X,Y>
execIfTrueAsMapEntry(IFunction<? super Map.Entry<K,V>,Boolean> eval, IFunction<? super Map.Entry<K,V>,? extends Map.Entry<X,Y>> function, IFunction<? super Map.Entry<K,V>,? extends Map.Entry<X,Y>> elseFunction)
           Executes a function in a way equivalent to ExecutableMapEntryOperator.execAsMapEntry(IFunction) but only on selected elements, leaving all other elements untouched.
 Map<K,V> get()
           Returns the target object this operator currently holds.
 Level1MapEntriesSelectedOperator<I,K,V> ifFalse(IFunction<? super Map.Entry<K,V>,Boolean> eval)
           Selects only those targets for which the specified evaluator returns false.
 Level1MapEntriesSelectedOperator<I,K,V> ifIndex(int... indexes)
           Selects only those targets which index in the current level of iteration matches any of the specified indexes.
 Level1MapEntriesSelectedOperator<I,K,V> ifIndexNot(int... indexes)
           Selects only those targets which index in the current level of iteration does not match any of the specified indexes.
 Level1MapEntriesSelectedOperator<I,K,V> ifKeyEquals(K... keys)
           Selects only those entries which key matches any of the specified values.
 Level1MapEntriesSelectedOperator<I,K,V> ifKeyNotEquals(K... keys)
           Selects only those entries which key does not match any of the specified values.
 Level1MapEntriesSelectedOperator<I,K,V> ifTrue(IFunction<? super Map.Entry<K,V>,Boolean> eval)
           Selects only those targets for which the specified evaluator returns true.
 Level2MapEntriesKeyOperator<I,K,V> onKey()
           Accesses the key of a map entry.
 Level2MapEntriesValueOperator<I,K,V> onValue()
           Accesses the value of a map entry.
 Level1MapEntriesOperator<I,K,V> replaceWith(Map.Entry<K,V> 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

Level1MapEntriesOperator

public Level1MapEntriesOperator(Target target)
Method Detail

endFor

public Level0MapOperator<I,K,V> endFor()
Description copied from interface: NavigatingMapOperator

Ends the current iteration. After the execution of this method, all subsequent operations will be applied on the iterated map as a whole instead of each entry.

Specified by:
endFor in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
endFor in interface NavigatingMapOperator<K,V>
Returns:
an operator which will execute all operations on the iterated map as a whole.

onKey

public Level2MapEntriesKeyOperator<I,K,V> onKey()
Description copied from interface: NavigableMapEntryOperator

Accesses the key of a map entry. After the execution of this method, all subsequent operations will be performed on the map entry's key, until an "endOn()" method is executed.

Specified by:
onKey in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
onKey in interface NavigableMapEntryOperator
Returns:
an operator which will execute all operations on the key of the map entry.

onValue

public Level2MapEntriesValueOperator<I,K,V> onValue()
Description copied from interface: NavigableMapEntryOperator

Accesses the value of a map entry. After the execution of this method, all subsequent operations will be performed on the map entry's value, until an "endOn()" method is executed.

Specified by:
onValue in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
onValue in interface NavigableMapEntryOperator
Returns:
an operator which will execute all operations on the value of the map entry.

get

public Map<K,V> get()
Description copied from interface: UniqOpOperator

Returns the target object this operator currently holds.

Specified by:
get in interface UniqOpOperator<I,Map<K,V>>
Returns:
the target object.

ifIndex

public Level1MapEntriesSelectedOperator<I,K,V> ifIndex(int... indexes)
Description copied from interface: SelectableMapEntryOperator

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 ILevel1MapEntriesOperator<I,K,V>
Specified by:
ifIndex in interface SelectableMapEntryOperator<K,V>
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 Level1MapEntriesSelectedOperator<I,K,V> ifIndexNot(int... indexes)
Description copied from interface: SelectableMapEntryOperator

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 ILevel1MapEntriesOperator<I,K,V>
Specified by:
ifIndexNot in interface SelectableMapEntryOperator<K,V>
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.

ifKeyEquals

public Level1MapEntriesSelectedOperator<I,K,V> ifKeyEquals(K... keys)
Description copied from interface: SelectableMapEntryOperator

Selects only those entries which key matches any of the specified values. 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:
ifKeyEquals in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
ifKeyEquals in interface SelectableMapEntryOperator<K,V>
Parameters:
keys - the key values to be matched
Returns:
an operator which will execute all subsequent operations only on the selected target objects.

ifKeyNotEquals

public Level1MapEntriesSelectedOperator<I,K,V> ifKeyNotEquals(K... keys)
Description copied from interface: SelectableMapEntryOperator

Selects only those entries which key does not match any of the specified values. 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:
ifKeyNotEquals in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
ifKeyNotEquals in interface SelectableMapEntryOperator<K,V>
Parameters:
keys - the key values to be matched
Returns:
an operator which will execute all subsequent operations only on the selected target objects.

ifTrue

public Level1MapEntriesSelectedOperator<I,K,V> ifTrue(IFunction<? super Map.Entry<K,V>,Boolean> eval)
Description copied from interface: SelectableMapEntryOperator

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 ILevel1MapEntriesOperator<I,K,V>
Specified by:
ifTrue in interface SelectableMapEntryOperator<K,V>
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 Level1MapEntriesSelectedOperator<I,K,V> ifFalse(IFunction<? super Map.Entry<K,V>,Boolean> eval)
Description copied from interface: SelectableMapEntryOperator

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 ILevel1MapEntriesOperator<I,K,V>
Specified by:
ifFalse in interface SelectableMapEntryOperator<K,V>
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.

execAsMapEntry

public <X,Y> Level1MapEntriesOperator<I,X,Y> execAsMapEntry(IFunction<? super Map.Entry<K,V>,? extends Map.Entry<X,Y>> function)
Description copied from interface: ExecutableMapEntryOperator

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

This function must be able to take as input an object of the current operator's target type, and will return an object of a different type but same structure, which will be from then on the new operator's target type.

Specified by:
execAsMapEntry in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
execAsMapEntry in interface ExecutableMapEntryOperator<K,V>
Type Parameters:
X - the type of the resulting keys
Y - the type of the resulting values
Parameters:
function - the function to be executed
Returns:
an operator on the results of function execution

exec

public <X> Level1ListElementsOperator<I,X> exec(IFunction<? super Map.Entry<K,V>,X> function)
Description copied from interface: ExecutableMapEntryOperator

Executes the specified function on the target map entry, creating a new generic operator containing the result of the execution and setting the new operator type to the one specified.

Specified by:
exec in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
exec in interface ExecutableMapEntryOperator<K,V>
Type Parameters:
X - the type of the result object
Parameters:
function - the function to be executed
Returns:
an operator on the results of function execution

replaceWith

public Level1MapEntriesOperator<I,K,V> replaceWith(Map.Entry<K,V> replacement)
Description copied from interface: ReplaceableOperator

Replaces the current target object with the specified replacement.

Specified by:
replaceWith in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
replaceWith in interface ReplaceableOperator<Map.Entry<K,V>>
Parameters:
replacement - the object which will replace the current target object.
Returns:
an operator containing the replacement object as target.

execIfFalseAsMapEntry

public Level1MapEntriesOperator<I,K,V> execIfFalseAsMapEntry(IFunction<? super Map.Entry<K,V>,Boolean> eval,
                                                             IFunction<? super Map.Entry<K,V>,? extends Map.Entry<? extends K,? extends V>> function)
Description copied from interface: ExecutableMapEntryOperator

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

Specified by:
execIfFalseAsMapEntry in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
execIfFalseAsMapEntry in interface ExecutableMapEntryOperator<K,V>
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

execIfFalseAsMapEntry

public <X,Y> Level1MapEntriesOperator<I,X,Y> execIfFalseAsMapEntry(IFunction<? super Map.Entry<K,V>,Boolean> eval,
                                                                   IFunction<? super Map.Entry<K,V>,? extends Map.Entry<X,Y>> function,
                                                                   IFunction<? super Map.Entry<K,V>,? extends Map.Entry<X,Y>> elseFunction)
Description copied from interface: ExecutableMapEntryOperator

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

Specified by:
execIfFalseAsMapEntry in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
execIfFalseAsMapEntry in interface ExecutableMapEntryOperator<K,V>
Type Parameters:
X - the new type of the keys returned by the functions
Y - the new type of the values 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

execIfTrueAsMapEntry

public Level1MapEntriesOperator<I,K,V> execIfTrueAsMapEntry(IFunction<? super Map.Entry<K,V>,Boolean> eval,
                                                            IFunction<? super Map.Entry<K,V>,? extends Map.Entry<? extends K,? extends V>> function)
Description copied from interface: ExecutableMapEntryOperator

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

Specified by:
execIfTrueAsMapEntry in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
execIfTrueAsMapEntry in interface ExecutableMapEntryOperator<K,V>
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

execIfTrueAsMapEntry

public <X,Y> Level1MapEntriesOperator<I,X,Y> execIfTrueAsMapEntry(IFunction<? super Map.Entry<K,V>,Boolean> eval,
                                                                  IFunction<? super Map.Entry<K,V>,? extends Map.Entry<X,Y>> function,
                                                                  IFunction<? super Map.Entry<K,V>,? extends Map.Entry<X,Y>> elseFunction)
Description copied from interface: ExecutableMapEntryOperator

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

Specified by:
execIfTrueAsMapEntry in interface ILevel1MapEntriesOperator<I,K,V>
Specified by:
execIfTrueAsMapEntry in interface ExecutableMapEntryOperator<K,V>
Type Parameters:
X - the new type of the keys returned by the functions
Y - the new type of the values 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.