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

Object
  extended by org.op4j.operators.impl.AbstractOperator
      extended by org.op4j.operators.impl.op.map.Level0MapSelectedOperator<I,K,V>
All Implemented Interfaces:
ILevel0MapSelectedOperator<I,K,V>, ExecutableMapSelectedOperator<K,V>, ModifiableMapOperator<K,V>, NavigableMapOperator<K,V>, Operator, ReplaceableOperator<Map<K,V>>, SelectedOperator<Map<K,V>>, SortableOperator<Map.Entry<K,V>>, UniqOperator<Map<K,V>>, UniqOpOperator<I,Map<K,V>>

public final class Level0MapSelectedOperator<I,K,V>
extends AbstractOperator
implements UniqOpOperator<I,Map<K,V>>, ILevel0MapSelectedOperator<I,K,V>


Constructor Summary
Level0MapSelectedOperator(Target target)
           
 
Method Summary
 Level0MapOperator<I,K,V> endIf()
           Ends the selection currently active for this level.
 Level0MapSelectedOperator<I,K,V> execAsMap(IFunction<? super Map<K,V>,? extends Map<? extends K,? extends V>> function)
           Executes the specified function on the target object, creating a new map operator containing the result of the execution.
 Level1MapSelectedEntriesOperator<I,K,V> forEachEntry()
           Iterates the target map's entries.
 Map<K,V> get()
           Returns the target object this operator currently holds.
 Level0MapSelectedOperator<I,K,V> insert(int position, K newKey, V newValue)
           Inserts a new entry with the specified key and value into the specified position (starting in 0) of the target map.
 Level0MapSelectedOperator<I,K,V> insertAll(int position, Map<K,V> map)
           Inserts all the entries in the specified map to the target map, in the specified position.
 Level0MapSelectedOperator<I,K,V> put(K newKey, V newValue)
           Adds a new entry with the specified key and value at the end of the target map.
 Level0MapSelectedOperator<I,K,V> putAll(Map<K,V> map)
           Adds all the entries in the specified map to the target map.
 Level0MapSelectedOperator<I,K,V> removeAllFalse(IFunction<? super Map.Entry<K,V>,Boolean> eval)
           Removes from the target map all the entries which evaluate as false using the specified evaluator.
 Level0MapSelectedOperator<I,K,V> removeAllKeys(K... keys)
           Removes from the target map all entries which keys match the ones specified.
 Level0MapSelectedOperator<I,K,V> removeAllKeysNot(K... keys)
           Removes from the target map all entries except those which keys match the ones specified.
 Level0MapSelectedOperator<I,K,V> removeAllTrue(IFunction<? super Map.Entry<K,V>,Boolean> eval)
           Removes from the target map all the entries which evaluate as true using the specified evaluator.
 Level0MapSelectedOperator<I,K,V> replaceWith(Map<K,V> replacement)
           Replaces the current target object with the specified replacement.
 Level0MapSelectedOperator<I,K,V> sort()
           Sorts the elements of the structure according to their natural ordering.
 Level0MapSelectedOperator<I,K,V> sort(Comparator<? super Map.Entry<K,V>> comparator)
           Sorts the elements of the structure according to the order induced by the specified comparator.
 Level0MapSelectedOperator<I,K,V> sortBy(IFunction<? super Map.Entry<K,V>,?> by)
           Sorts the elements of the structure according to the result of executing the specified function.
 
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

Level0MapSelectedOperator

public Level0MapSelectedOperator(Target target)
Method Detail

sortBy

public Level0MapSelectedOperator<I,K,V> sortBy(IFunction<? super Map.Entry<K,V>,?> by)
Description copied from interface: SortableOperator

Sorts the elements of the structure according to the result of executing the specified function.

Specified by:
sortBy in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
sortBy in interface SortableOperator<Map.Entry<K,V>>
Parameters:
by - the function to be executed in order to obtain the compared object
Returns:
an operator containing the sorted structure as target object.

insertAll

public Level0MapSelectedOperator<I,K,V> insertAll(int position,
                                                  Map<K,V> map)
Description copied from interface: ModifiableMapOperator

Inserts all the entries in the specified map to the target map, in the specified position.

The original target object is not modified, but copied instead.

Specified by:
insertAll in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
insertAll in interface ModifiableMapOperator<K,V>
Parameters:
position - the position into which the entries will be added.
map - the map containing the entries to be inserted.
Returns:
an operator holding the modified map

removeAllTrue

public Level0MapSelectedOperator<I,K,V> removeAllTrue(IFunction<? super Map.Entry<K,V>,Boolean> eval)
Description copied from interface: ModifiableMapOperator

Removes from the target map all the entries which evaluate as true using the specified evaluator.

The original target object is not modified, but copied instead.

Specified by:
removeAllTrue in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
removeAllTrue in interface ModifiableMapOperator<K,V>
Parameters:
eval - the evaluator to be used, which must return Boolean
Returns:
an operator holding the modified map

removeAllFalse

public Level0MapSelectedOperator<I,K,V> removeAllFalse(IFunction<? super Map.Entry<K,V>,Boolean> eval)
Description copied from interface: ModifiableMapOperator

Removes from the target map all the entries which evaluate as false using the specified evaluator.

The original target object is not modified, but copied instead.

Specified by:
removeAllFalse in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
removeAllFalse in interface ModifiableMapOperator<K,V>
Parameters:
eval - the evaluator to be used, which must return Boolean
Returns:
an operator holding the modified map

endIf

public Level0MapOperator<I,K,V> endIf()
Description copied from interface: SelectedOperator

Ends the selection currently active for this level.

Specified by:
endIf in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
endIf in interface SelectedOperator<Map<K,V>>
Returns:
an operator which will execute all subsequent operations on all the target objects instead of only on the previously selected ones.

forEachEntry

public Level1MapSelectedEntriesOperator<I,K,V> forEachEntry()
Description copied from interface: NavigableMapOperator

Iterates the target map's entries. After executing this method, any further operations will be applied on each of the map entries (java.util.Map.Entry objects) until an "endFor()" method is called.

Specified by:
forEachEntry in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
forEachEntry in interface NavigableMapOperator<K,V>
Returns:
an operator which will execute all operations on each entry of the map.

removeAllKeys

public Level0MapSelectedOperator<I,K,V> removeAllKeys(K... keys)
Description copied from interface: ModifiableMapOperator

Removes from the target map all entries which keys match the ones specified.

The original target object is not modified, but copied instead.

Specified by:
removeAllKeys in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
removeAllKeys in interface ModifiableMapOperator<K,V>
Parameters:
keys - the keys which have to be removed.
Returns:
an operator holding the modified map

removeAllKeysNot

public Level0MapSelectedOperator<I,K,V> removeAllKeysNot(K... keys)
Description copied from interface: ModifiableMapOperator

Removes from the target map all entries except those which keys match the ones specified.

The original target object is not modified, but copied instead.

Specified by:
removeAllKeysNot in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
removeAllKeysNot in interface ModifiableMapOperator<K,V>
Parameters:
keys - the keys which have to be kept.
Returns:
an operator holding the modified map

execAsMap

public Level0MapSelectedOperator<I,K,V> execAsMap(IFunction<? super Map<K,V>,? extends Map<? extends K,? extends V>> function)
Description copied from interface: ExecutableMapSelectedOperator

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

This function does not allow the operator target type to change because a selection ("if") has already been done on the target objects, and this would render the operator inconsistent (some objects would belong to a type and others to another type).

Specified by:
execAsMap in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
execAsMap in interface ExecutableMapSelectedOperator<K,V>
Parameters:
function - the function to be executed
Returns:
an operator on the results of function execution

put

public Level0MapSelectedOperator<I,K,V> put(K newKey,
                                            V newValue)
Description copied from interface: ModifiableMapOperator

Adds a new entry with the specified key and value at the end of the target map.

The original target object is not modified, but copied instead.

Specified by:
put in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
put in interface ModifiableMapOperator<K,V>
Parameters:
newKey - the key for the new entry to be added
newValue - the value for the new entry to be added
Returns:
an operator holding the modified map

putAll

public Level0MapSelectedOperator<I,K,V> putAll(Map<K,V> map)
Description copied from interface: ModifiableMapOperator

Adds all the entries in the specified map to the target map.

The original target object is not modified, but copied instead.

Specified by:
putAll in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
putAll in interface ModifiableMapOperator<K,V>
Parameters:
map - the map containing the entries to be added.
Returns:
an operator holding the modified map

insert

public Level0MapSelectedOperator<I,K,V> insert(int position,
                                               K newKey,
                                               V newValue)
Description copied from interface: ModifiableMapOperator

Inserts a new entry with the specified key and value into the specified position (starting in 0) of the target map.

The original target object is not modified, but copied instead.

Specified by:
insert in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
insert in interface ModifiableMapOperator<K,V>
Parameters:
position - the position into which the new entry will be inserted
newKey - the key for the new entry to be insert
newValue - the value for the new entry to be insert
Returns:
an operator holding the modified map

sort

public Level0MapSelectedOperator<I,K,V> sort()
Description copied from interface: SortableOperator

Sorts the elements of the structure according to their natural ordering.

Specified by:
sort in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
sort in interface SortableOperator<Map.Entry<K,V>>
Returns:
an operator containing the sorted structure as target object.

sort

public Level0MapSelectedOperator<I,K,V> sort(Comparator<? super Map.Entry<K,V>> comparator)
Description copied from interface: SortableOperator

Sorts the elements of the structure according to the order induced by the specified comparator.

Specified by:
sort in interface ILevel0MapSelectedOperator<I,K,V>
Specified by:
sort in interface SortableOperator<Map.Entry<K,V>>
Parameters:
comparator - the comparator to be used.
Returns:
an operator containing the sorted structure as target object.

replaceWith

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

Replaces the current target object with the specified replacement.

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

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.


Copyright © 2012 The OP4J team. All Rights Reserved.