org.op4j.operators.impl.op.array
Class Level0IndefiniteArrayOperator<I,T>

Object
  extended by org.op4j.operators.impl.AbstractOperator
      extended by org.op4j.operators.impl.op.array.Level0IndefiniteArrayOperator<I,T>
All Implemented Interfaces:
ILevel0IndefiniteArrayOperator<I,T>, CastableToArrayOperator, ConvertibleToListOperator, ConvertibleToMapOperator<T>, ConvertibleToSetOperator, ExecutableIndefiniteArrayOperator<I,T>, GenerizableOperator<I,T[]>, Operator, ReversibleOperator<T>, UniqOperator<T[]>, UniqOpOperator<I,T[]>

public final class Level0IndefiniteArrayOperator<I,T>
extends AbstractOperator
implements UniqOpOperator<I,T[]>, ILevel0IndefiniteArrayOperator<I,T>

Since:
1.0
Author:
Daniel Fernández

Constructor Summary
Level0IndefiniteArrayOperator(Target target)
           
 
Method Summary
<X> Level0ArrayOperator<I,X>
castToArrayOf(org.javaruntype.type.Type<X> newType)
           Casts the operator's target as an array of the specified type.
 Level0MapOperator<I,T,T> couple()
           Converts the target object to a map, by using the even elements (starting at 0) as keys, and the odd elements as values.
<X> Level0GenericUniqOperator<I,X>
exec(IFunction<? super T[],X> function)
           Executes the specified function on the target object, creating a new generic operator containing the result of the execution.
 Level0GenericUniqOperator<I,T[]> generic()
           Converts the specialized structure operator into generic operators (with no specific methods for structures - e.g. forEach())
 T[] get()
           Returns the target object this operator currently holds.
<X> Level0ArrayOperator<I,X>
of(org.javaruntype.type.Type<X> newType)
           Casts the operator's target as an array of the specified type.
 Level0IndefiniteArrayOperator<I,T> reverse()
           Reverses the elements of the structure.
<K,V> Level0MapOperator<I,K,V[]>
toGroupMapOf(org.javaruntype.type.Type<V> valueType, IFunction<? super T,K> keyFunction, IFunction<? super T,V> valueFunction)
           
<K,V> Level0MapOperator<I,K,V[]>
toGroupMapOf(org.javaruntype.type.Type<V> valueType, IFunction<? super T,Map.Entry<K,V>> mapBuilder)
           
 Level0ListOperator<I,T> toList()
           Converts the current target to a list.
<K,V> Level0MapOperator<I,K,V>
toMap(IFunction<? super T,K> keyFunction, IFunction<? super T,V> valueFunction)
           Converts the target object to a map by inputting the original target's elements into the specified functions, which will create the resulting keys and values.
<K,V> Level0MapOperator<I,K,V>
toMap(IFunction<? super T,Map.Entry<K,V>> mapBuilder)
           Converts the target object to a map by inputting the original target's elements into the specified map builder (a function returning map entries) which will create the resulting keys and values.
 Level0SetOperator<I,T> toSet()
           Converts the current target into a set.
<K> Level0MapOperator<I,K,T>
zipKeys(K... keys)
           Converts the target object to a map by using the original target's elements as values and setting the specified objects as keys.
<K> Level0MapOperator<I,K,T>
zipKeysBy(IFunction<? super T,K> keyEval)
           Converts the target object to a map by using the original target's elements as values and applying an evaluator (keyEval) to them in order to obtain their corresponding keys.
<K> Level0MapOperator<I,K,T>
zipKeysFrom(Collection<K> keys)
           Converts the target object to a map by using the original target's elements as values and setting the specified objects as keys.
<K> Level0MapOperator<I,K,T>
zipKeysFrom(K[] keys)
           Converts the target object to a map by using the original target's elements as values and setting the specified objects as keys.
<V> Level0MapOperator<I,T,V>
zipValues(V... values)
           Converts the target object to a map by using the original target's elements as keys and applying an evaluator (valueEval) to them in order to obtain their corresponding value.
<V> Level0MapOperator<I,T,V>
zipValuesBy(IFunction<? super T,V> valueEval)
           Converts the target object to a map by using the original target's elements as keys and applying an evaluator (valueEval) to them in order to obtain their corresponding value.
<V> Level0MapOperator<I,T,V>
zipValuesFrom(Collection<V> values)
           Converts the target object to a map by using the original target's elements as keys and applying an evaluator (valueEval) to them in order to obtain their corresponding value.
<V> Level0MapOperator<I,T,V>
zipValuesFrom(V[] values)
           Converts the target object to a map by using the original target's elements as keys and applying an evaluator (valueEval) to them in order to obtain their corresponding 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

Level0IndefiniteArrayOperator

public Level0IndefiniteArrayOperator(Target target)
Method Detail

toList

public Level0ListOperator<I,T> toList()
Description copied from interface: ConvertibleToListOperator

Converts the current target to a list.

Specified by:
toList in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
toList in interface ConvertibleToListOperator
Returns:
an operator holding the converted object as target.

couple

public Level0MapOperator<I,T,T> couple()
Description copied from interface: ConvertibleToMapOperator

Converts the target object to a map, by using the even elements (starting at 0) as keys, and the odd elements as values.

Specified by:
couple in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
couple in interface ConvertibleToMapOperator<T>
Returns:
an operator holding the converted object as target.

zipKeysBy

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

Converts the target object to a map by using the original target's elements as values and applying an evaluator (keyEval) to them in order to obtain their corresponding keys.

Note that if more than one value get the same key, only the last one will be in the resulting map (the other ones will be overwritten).

Specified by:
zipKeysBy in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
zipKeysBy in interface ConvertibleToMapOperator<T>
Type Parameters:
K - the type of the keys that will be created
Parameters:
keyEval - the evaluator used for obtaining the keys
Returns:
an operator holding the converted object as target.

zipValuesBy

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

Converts the target object to a map by using the original target's elements as keys and applying an evaluator (valueEval) to them in order to obtain their corresponding value.

Note that if more than one value get the same key, only the last one will be in the resulting map (the other ones will be overwritten).

Specified by:
zipValuesBy in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
zipValuesBy in interface ConvertibleToMapOperator<T>
Type Parameters:
V - the type of the values that will be created
Parameters:
valueEval - the evaluator used for obtaining the values
Returns:
an operator holding the converted object as target.

zipKeys

public <K> Level0MapOperator<I,K,T> zipKeys(K... keys)
Description copied from interface: ConvertibleToMapOperator

Converts the target object to a map by using the original target's elements as values and setting the specified objects as keys.

Note that if more than one value get the same key, only the last one will be in the resulting map (the other ones will be overwritten).

Specified by:
zipKeys in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
zipKeys in interface ConvertibleToMapOperator<T>
Type Parameters:
K - the type of the keys
Parameters:
keys - the new keys
Returns:
an operator holding the converted object as target.

zipValues

public <V> Level0MapOperator<I,T,V> zipValues(V... values)
Description copied from interface: ConvertibleToMapOperator

Converts the target object to a map by using the original target's elements as keys and applying an evaluator (valueEval) to them in order to obtain their corresponding value.

Specified by:
zipValues in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
zipValues in interface ConvertibleToMapOperator<T>
Type Parameters:
V - the type of the values
Parameters:
values - the new values
Returns:
an operator holding the converted object as target.

toMap

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

Converts the target object to a map by inputting the original target's elements into the specified map builder (a function returning map entries) which will create the resulting keys and values.

Note that if more than one value get the same key, only the last one will be in the resulting map (the other ones will be overwritten).

Specified by:
toMap in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
toMap in interface ConvertibleToMapOperator<T>
Type Parameters:
K - the type of the keys that will be created
V - the type of the values that will be created
Parameters:
mapBuilder - the map builder function to be used
Returns:
an operator holding the converted object as target.

toGroupMapOf

public <K,V> Level0MapOperator<I,K,V[]> toGroupMapOf(org.javaruntype.type.Type<V> valueType,
                                                     IFunction<? super T,Map.Entry<K,V>> mapBuilder)
Specified by:
toGroupMapOf in interface ILevel0IndefiniteArrayOperator<I,T>

toSet

public Level0SetOperator<I,T> toSet()
Description copied from interface: ConvertibleToSetOperator

Converts the current target into a set.

Specified by:
toSet in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
toSet in interface ConvertibleToSetOperator
Returns:
an operator holding the converted object as target.

generic

public Level0GenericUniqOperator<I,T[]> generic()
Description copied from interface: GenerizableOperator

Converts the specialized structure operator into generic operators (with no specific methods for structures - e.g. forEach())

Specified by:
generic in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
generic in interface GenerizableOperator<I,T[]>
Returns:
a generic operator on the same target object

exec

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

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

This function must be able to take as input an array 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 ILevel0IndefiniteArrayOperator<I,T>
Specified by:
exec in interface ExecutableIndefiniteArrayOperator<I,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

of

public <X> Level0ArrayOperator<I,X> of(org.javaruntype.type.Type<X> newType)
Description copied from interface: CastableToArrayOperator

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

Specified by:
of in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
of in interface CastableToArrayOperator
Type Parameters:
X - the type of the elements of the array
Parameters:
newType - the type of the elements of the array
Returns:
the resulting casted operator

castToArrayOf

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

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

Specified by:
castToArrayOf in interface CastableToArrayOperator
Type Parameters:
X - the type of the elements of the array
Parameters:
newType - the type of the elements of the array
Returns:
the resulting casted operator

zipKeysFrom

public <K> Level0MapOperator<I,K,T> zipKeysFrom(Collection<K> keys)
Description copied from interface: ConvertibleToMapOperator

Converts the target object to a map by using the original target's elements as values and setting the specified objects as keys.

Note that if more than one value get the same key, only the last one will be in the resulting map (the other ones will be overwritten).

Specified by:
zipKeysFrom in interface ConvertibleToMapOperator<T>
Type Parameters:
K - the type of the keys
Parameters:
keys - the new keys
Returns:
an operator holding the converted object as target.

zipKeysFrom

public <K> Level0MapOperator<I,K,T> zipKeysFrom(K[] keys)
Description copied from interface: ConvertibleToMapOperator

Converts the target object to a map by using the original target's elements as values and setting the specified objects as keys.

Note that if more than one value get the same key, only the last one will be in the resulting map (the other ones will be overwritten).

Specified by:
zipKeysFrom in interface ConvertibleToMapOperator<T>
Type Parameters:
K - the type of the keys
Parameters:
keys - the new keys
Returns:
an operator holding the converted object as target.

zipValuesFrom

public <V> Level0MapOperator<I,T,V> zipValuesFrom(Collection<V> values)
Description copied from interface: ConvertibleToMapOperator

Converts the target object to a map by using the original target's elements as keys and applying an evaluator (valueEval) to them in order to obtain their corresponding value.

Specified by:
zipValuesFrom in interface ConvertibleToMapOperator<T>
Type Parameters:
V - the type of the values
Parameters:
values - the new values
Returns:
an operator holding the converted object as target.

zipValuesFrom

public <V> Level0MapOperator<I,T,V> zipValuesFrom(V[] values)
Description copied from interface: ConvertibleToMapOperator

Converts the target object to a map by using the original target's elements as keys and applying an evaluator (valueEval) to them in order to obtain their corresponding value.

Specified by:
zipValuesFrom in interface ConvertibleToMapOperator<T>
Type Parameters:
V - the type of the values
Parameters:
values - the new values
Returns:
an operator holding the converted object as target.

reverse

public Level0IndefiniteArrayOperator<I,T> reverse()
Description copied from interface: ReversibleOperator

Reverses the elements of the structure.

Specified by:
reverse in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
reverse in interface ReversibleOperator<T>
Returns:
an operator containing the reversed structure as target object.

toGroupMapOf

public <K,V> Level0MapOperator<I,K,V[]> toGroupMapOf(org.javaruntype.type.Type<V> valueType,
                                                     IFunction<? super T,K> keyFunction,
                                                     IFunction<? super T,V> valueFunction)
Specified by:
toGroupMapOf in interface ILevel0IndefiniteArrayOperator<I,T>

toMap

public <K,V> Level0MapOperator<I,K,V> toMap(IFunction<? super T,K> keyFunction,
                                            IFunction<? super T,V> valueFunction)
Description copied from interface: ConvertibleToMapOperator

Converts the target object to a map by inputting the original target's elements into the specified functions, which will create the resulting keys and values.

Note that if more than one value get the same key, only the last one will be in the resulting map (the other ones will be overwritten).

Specified by:
toMap in interface ILevel0IndefiniteArrayOperator<I,T>
Specified by:
toMap in interface ConvertibleToMapOperator<T>
Type Parameters:
K - the type of the keys that will be created
V - the type of the values that will be created
Parameters:
keyFunction - the function for building the keys
valueFunction - the function for building the values
Returns:
an operator holding the converted object as target.

get

public T[] get()
Description copied from interface: UniqOpOperator

Returns the target object this operator currently holds.

Specified by:
get in interface UniqOpOperator<I,T[]>
Returns:
the target object.


Copyright © 2012 The OP4J team. All Rights Reserved.