public final class Builtins
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static com.google.common.collect.ImmutableList<java.lang.Integer> |
MAXIMUM_PARSER_VERSION
This variable is used by the interpreter for providing compatibility hints in the Eclipse plugin.
|
static com.google.common.collect.ImmutableList<java.lang.Integer> |
MINIMUM_PARSER_VERSION
This variable is used by the interpreter for providing compatibility hints in the Eclipse plugin.
|
Modifier and Type | Method and Description |
---|---|
static boolean |
all(Field<java.lang.Boolean> target) |
static boolean |
allButSelf(Field<java.lang.Boolean> target) |
static boolean |
any(Field<java.lang.Boolean> target) |
static boolean |
anyButSelf(Field<java.lang.Boolean> target) |
static <T> T |
foldHood(ExecutionContext context,
T base,
Field<T> target,
FunctionDefinition reductionFunction)
Folds a field, excluding the local value.
|
static <T> T |
foldHoodPlusSelf(ExecutionContext context,
Field<T> target,
FunctionDefinition reductionFunction)
Folds the field, including the local value.
|
static <T extends java.lang.Comparable<T>> |
foldMax(Field<T> target)
Folds the field, including the local value, by picking the maximum value.
|
static <T extends java.lang.Comparable<T>> |
foldMax(T base,
Field<T> target)
Folds a field by picking the maximum of its values, excluding the local
value.
|
static double |
foldMean(Field<? extends java.lang.Number> target)
Folds a field of numbers by computing the mathematical mean.
|
static <T extends java.lang.Comparable<T>> |
foldMin(Field<T> target)
Folds the field, including the local value, by picking the minimum value.
|
static <T extends java.lang.Comparable<T>> |
foldMin(T base,
Field<T> target)
Folds a field by picking the minimum of its values, excluding the local
value.
|
static <T> T |
foldSum(Field<T> target)
Folds the field, including the local value, by computing the sum.
|
static <T> T |
foldSum(T base,
Field<T> target)
Folds a field by computing the sum of its values, excluding the local
value.
|
static <T> T |
foldUnion(Field<T> target)
Folds the field, including the local value, by computing the union.
|
static <T> T |
foldUnion(T base,
Field<T> target)
Folds a field by computing the union, excluding the local value.
|
static <T> T |
local(Field<T> target)
Picks the local field value (same operation of the previously available
"localHood" and "pickHood").
|
static <T> Option<T> |
maybe(T object)
Given a nullable reference, builds an
Option . |
static boolean |
none(Field<java.lang.Boolean> target) |
static boolean |
noneButSelf(Field<java.lang.Boolean> target) |
static <T> Option<T> |
optionally(T object)
Produces an Option value.
|
static <T> Option<T> |
reduceHood(ExecutionContext context,
Field<T> target,
FunctionDefinition reductionFunction)
Reduces a field, excluding the local value.
|
static <T extends java.lang.Comparable<T>> |
reduceMax(Field<T> target)
Reduces a field, excluding the local value, by picking the maximum
value.
|
static Option<java.lang.Double> |
reduceMean(Field<? extends java.lang.Number> target)
Reduces a field, excluding the local value, by computing the
arithmetic mean of the values.
|
static <T extends java.lang.Comparable<T>> |
reduceMin(Field<T> target)
Reduces a field by picking the minimum of its values, excluding the local
value.
|
static <T> Option<T> |
reduceSum(Field<T> target)
Reduces a field, excluding the local value, by computing the sum of
the values.
|
static <T> Option<T> |
reduceUnion(Field<T> target)
Reduces a field, excluding the local value, by computing the union of
the values.
|
public static final com.google.common.collect.ImmutableList<java.lang.Integer> MINIMUM_PARSER_VERSION
public static final com.google.common.collect.ImmutableList<java.lang.Integer> MAXIMUM_PARSER_VERSION
public static boolean all(Field<java.lang.Boolean> target)
target
- the fieldpublic static boolean allButSelf(Field<java.lang.Boolean> target)
target
- the fieldpublic static boolean any(Field<java.lang.Boolean> target)
target
- the fieldpublic static boolean anyButSelf(Field<java.lang.Boolean> target)
target
- the fieldpublic static <T> T foldHood(@Nonnull ExecutionContext context, @Nonnull T base, @Nonnull Field<T> target, @Nonnull FunctionDefinition reductionFunction)
T
- field and result typecontext
- ExecutionContext
target
- the field to be reducedreductionFunction
- the reduction functionbase
- the base valueOption
with the result of the field reduction, or an empty
option.public static <T> T foldHoodPlusSelf(@Nonnull ExecutionContext context, @Nonnull Field<T> target, @Nonnull FunctionDefinition reductionFunction)
T
- field and result typecontext
- ExecutionContext
target
- target fieldreductionFunction
- a Protelis function (T, T)=>Tpublic static <T extends java.lang.Comparable<T>> T foldMax(Field<T> target)
Comparable
.T
- field and result typetarget
- target fieldpublic static <T extends java.lang.Comparable<T>> T foldMax(T base, Field<T> target)
Comparable
.T
- field and result typetarget
- the field to be reducedbase
- the base valuepublic static double foldMean(Field<? extends java.lang.Number> target)
target
- the field to be reducedDouble
with the arithmetic mean of the valuespublic static <T extends java.lang.Comparable<T>> T foldMin(Field<T> target)
Comparable
.T
- field and result typetarget
- target fieldpublic static <T extends java.lang.Comparable<T>> T foldMin(T base, Field<T> target)
Comparable
.T
- field and result typetarget
- the field to be reducedbase
- the base valuepublic static <T> T foldSum(Field<T> target)
T
- field and result typetarget
- target fieldpublic static <T> T foldSum(T base, Field<T> target)
T
- field and result typetarget
- the field to be reducedbase
- the base valuepublic static <T> T foldUnion(Field<T> target)
T
- field and result typetarget
- target fieldpublic static <T> T foldUnion(T base, Field<T> target)
T
- field and result typetarget
- the field to be reducedbase
- the base valuepublic static <T> T local(Field<T> target)
T
- field and result typetarget
- the field to be reducedpublic static <T> Option<T> maybe(@Nullable T object)
Option
.public static boolean none(Field<java.lang.Boolean> target)
target
- the fieldpublic static boolean noneButSelf(Field<java.lang.Boolean> target)
target
- the fieldpublic static <T> Option<T> reduceHood(@Nonnull ExecutionContext context, @Nonnull Field<T> target, @Nonnull FunctionDefinition reductionFunction)
Option
. If the field only contains the local value, then
an empty Option
is returned.T
- field and result typecontext
- ExecutionContext
target
- the field to be reducedreductionFunction
- the reduction functionOption
with the result of the field reduction, or an empty
option.public static <T> Option<T> optionally(@Nullable T object)
T
- Object typeobject
- the nullable objectpublic static <T extends java.lang.Comparable<T>> Option<T> reduceMax(Field<T> target)
Option
. If the field only
contains the local value, then an empty Option
is returned.T
- field and result typetarget
- the field to be reducedOption
with the result of the field reduction, or an empty
option.public static Option<java.lang.Double> reduceMean(Field<? extends java.lang.Number> target)
Option
. If the field only contains the local value, then an empty
Option
is returned.target
- the field to be reducedOption
with the result of the field reduction, or an empty
option.public static <T extends java.lang.Comparable<T>> Option<T> reduceMin(Field<T> target)
Option
. If the field
only contains the local value, then an empty Option
is returned.T
- field and result typetarget
- the field to be reducedOption
with the result of the field reduction, or an empty
option.public static <T> Option<T> reduceSum(Field<T> target)
Option
. If the field
only contains the local value, then an empty Option
is returned.T
- field and result typetarget
- the field to be reducedOption
with the result of the field reduction, or an empty
option.public static <T> Option<T> reduceUnion(Field<T> target)
Option
. If the field
only contains the local value, then an empty Option
is returned.T
- field and result typetarget
- the field to be reducedOption
with the result of the field reduction, or an empty
option.