Class JxnF2
- java.lang.Object
-
- JxnFunction
-
- JxnF2
-
- All Implemented Interfaces:
Comparator
,BiConsumer
,BiFunction
,BinaryOperator
,BiPredicate
,DoubleBinaryOperator
,IntBinaryOperator
,LongBinaryOperator
,ObjDoubleConsumer
,ObjIntConsumer
,ObjLongConsumer
,ToDoubleBiFunction
,ToIntBiFunction
,ToLongBiFunction
public class JxnF2 extends JxnFunction implements Comparator, BiPredicate, BiFunction, ToIntBiFunction, ToLongBiFunction, ToDoubleBiFunction, BinaryOperator, IntBinaryOperator, LongBinaryOperator, DoubleBinaryOperator, BiConsumer, ObjIntConsumer, ObjLongConsumer, ObjDoubleConsumer
The classesJxnF
,JxnF2
,JxnI
,JxnL
andJxnD
together implement all interfaces of packagejava.util.function
forjava.util.stream
. This allows to explore and use java → aggregate operations interactively from JXN.JxnF
implements all single or zero parameter methods,JxnF2
all double parameter methods andJxnI
,JxnL
andJxnD
methods incompatible withPredicate
.- See Also:
- AggregateOperations_Demo.jxn
-
-
Constructor Summary
Constructors Constructor Description JxnF2(JxnFunction f)
ConstructsJxnF2
from an already definedJxnFunction f
.JxnF2(KmgFormelInterpreter fi, String cmd)
Calls constructorJxnFunction( fi, cmd )
.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(Object t, double value)
void
accept(Object t, int value)
void
accept(Object t, long value)
void
accept(Object t, Object u)
Object
apply(Object t, Object u)
ImplementsBiFunction
,BinaryOperator
forStream
.reduce(…)
,Collector
.of(…)
,Collectors
.toMap(…)
,.toConcurrentMap(…)
,.reducing(…)
.double
applyAsDouble(double left, double right)
double
applyAsDouble(Object t, Object u)
ImplementsToDoubleBiFunction
.int
applyAsInt(int left, int right)
int
applyAsInt(Object t, Object u)
ImplementsToIntBiFunction
.long
applyAsLong(long left, long right)
long
applyAsLong(Object t, Object u)
ImplementsToLongBiFunction
.int
compare(Object o1, Object o2)
ImplementsComparator
.protected Object
exec(Object[] args)
Mapsargs
to$_
and the names passed to the constructor viaparameterNames
.protected Object
execute(Object o1, Object o2)
boolean
test(Object t, Object u)
ImplementsBiPredicate
.-
Methods inherited from interface java.util.function.BiConsumer
andThen
-
Methods inherited from interface java.util.function.BiFunction
andThen
-
Methods inherited from interface java.util.function.BinaryOperator
-
Methods inherited from interface java.util.function.BiPredicate
and, negate, or
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
Methods inherited from class JxnFunction
getArityLenience, getDebug, getShowConditional, getShowInternalResults, setArityLenience, setDebug, setShowConditional, setShowInternalResults, toString
-
-
-
-
Constructor Detail
-
JxnF2
public JxnF2(JxnFunction f)
ConstructsJxnF2
from an already definedJxnFunction f
.
Can be used, iff
is defined using jxn special commands:#function f ... #endfunction
Example:#function reverse( s1, s2 ) s2.
compareTo
( s1 ) ! reverse order #endfunction sa = { "DEF", "abc", "XYZ", "ghi", "___" };Arrays.sort
(sa); sa = { DEF, XYZ, ___, abc, ghi } (java.lang.String[5])Arrays.sort
( sa, @JxnF2( reverse ) ); sa = { ghi, abc, ___, XYZ, DEF } (java.lang.String[5])
-
JxnF2
public JxnF2(KmgFormelInterpreter fi, String cmd)
Calls constructorJxnFunction( fi, cmd )
.
Example:sa = { "DEF", "abc", "XYZ", "ghi", "___" };
Arrays.sort
(sa); sa = { DEF, XYZ, ___, abc, ghi } (java.lang.String[5])Arrays.sort
( sa, @JxnF2( $this, "( s1, s2 ) -> s1.compareToIgnoreCase
s2" ) ); sa = { ___, abc, DEF, ghi, XYZ } (java.lang.String[5])- Parameters:
cmd
- statement_sequence (one or more statements separated by';'
) or #filename[.jxn]. (Note: jxn does not support{…}
blocks as possible in java → lambda expressions)
-
-
Method Detail
-
exec
protected Object exec(Object[] args)
Description copied from class:JxnFunction
Mapsargs
to$_
and the names passed to the constructor viaparameterNames
.
Example:
fn = @JxnFunction( … ) !
calls a constructor to create a function instancefn
:
fn( arg1, arg2, ..., argN ) !
⇒ jxn internally callsfn.exec( { arg1, arg2, ..., argN } )
- Overrides:
exec
in classJxnFunction
-
compare
public int compare(Object o1, Object o2)
ImplementsComparator
.- Specified by:
compare
in interfaceComparator
-
test
public boolean test(Object t, Object u)
ImplementsBiPredicate
.- Specified by:
test
in interfaceBiPredicate
-
apply
public Object apply(Object t, Object u)
ImplementsBiFunction
,BinaryOperator
forStream
.reduce(…)
,Collector
.of(…)
,Collectors
.toMap(…)
,.toConcurrentMap(…)
,.reducing(…)
.- Specified by:
apply
in interfaceBiFunction
-
applyAsInt
public int applyAsInt(Object t, Object u)
ImplementsToIntBiFunction
.- Specified by:
applyAsInt
in interfaceToIntBiFunction
-
applyAsLong
public long applyAsLong(Object t, Object u)
ImplementsToLongBiFunction
.- Specified by:
applyAsLong
in interfaceToLongBiFunction
-
applyAsDouble
public double applyAsDouble(Object t, Object u)
ImplementsToDoubleBiFunction
.- Specified by:
applyAsDouble
in interfaceToDoubleBiFunction
-
applyAsInt
public int applyAsInt(int left, int right)
- Specified by:
applyAsInt
in interfaceIntBinaryOperator
-
applyAsLong
public long applyAsLong(long left, long right)
- Specified by:
applyAsLong
in interfaceLongBinaryOperator
-
applyAsDouble
public double applyAsDouble(double left, double right)
- Specified by:
applyAsDouble
in interfaceDoubleBinaryOperator
-
accept
public void accept(Object t, Object u)
ImplementsBiConsumer
forStream<T>
.collect(…)
,IntStream
.collect(…)
,LongStream
.collect(…)
,DoubleStream
.collect(…)
,Collector
.of(…)
.- Specified by:
accept
in interfaceBiConsumer
-
accept
public void accept(Object t, int value)
- Specified by:
accept
in interfaceObjIntConsumer
-
accept
public void accept(Object t, long value)
- Specified by:
accept
in interfaceObjLongConsumer
-
accept
public void accept(Object t, double value)
- Specified by:
accept
in interfaceObjDoubleConsumer
-
-