Class ParsedOp
- All Implemented Interfaces:
io.nosqlbench.nb.api.config.fieldreaders.DynamicFieldReader,io.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader,LongFunction<Map<String,?>>
ParsedOp API
This is the primary developer-focused API for driver developers to use when up-converting op templates
to operations. This ParsedOp is a wrapper around the op template structure. It provides many
ways of constructing higher-order objects from a variety of sources.
Supporting Variety
For some drivers or protocols, the primary user interface is a statement format or grammar. For CQL or SQL, the most natural way of describing templates for operations is in that native format. For others, an operation template may look like a block of JSON or a HTTP request. All these forms are supported. In order to deal with the variety, there is a set of detailed rules for how the workload definitions are transformed into driver operations for a native driver. The high-level flow is:
- Op Template Form
- Normalized Data Structure
- ParsedOp Form
Op Template Parsing
- Rule #1: All op templates are parsed into an internal normalized structure which contains:
- A map of op fields, which can consist of:
- static field values
- dynamic field values, the actual value of which can only be known for a given cycle
- Access to auxiliary configuration values like activity parameters. These can back-fill when values aren't present in the direct static or dynamic op fields.
- A map of op fields, which can consist of:
- Rule #2: When asking for a dynamic parameter, static parameters may be automatically promoted to functional form as a back-fill.
- Rule #3: When asking for static parameters, config parameters may automatically be promoted as a back-fill.
Distinguishing Op Payload from Op Config
When a user specifies an op template, they may choose to provide only a single set of op fields without distinguishing between config or payload, or they may choose to directly configure each.
Example:
ops:
# both op and params explicitly named
op1:
op:
opfield1: value1
params:
param2: value2
# neither op field nor params named, so all assumed to be op fields
op2:
opfield1: value1
param2: value2
# in this case, if param2 is meant to be config level,
# it is a likely config error that should be thrown to the user
# only op field explicitly named, so remainder automatically pushed into params
op3:
op:
opfield1: value1
param2: value2
# only params explicitly named, so remainder pushed into op payload
op4:
params:
param2: value2
opfield1: value1
All of these are considered valid constructions, and all of them may actually achieve the same result.
This looks like an undesirable problem, but it serves to simplify things for users in one specific way: It allows
them to be a vague, within guidelines, and still have a valid workload definition.
The NoSQLBench runtime does a non-trivial amount of processing on the op template to
ensure that it can conform to an unambiguous normalized internal structure on your behalf.
This is needed because of how awful YAML is as a user configuration language in spite of its
ubiquity in practice. The basic design guideline for these forms is that the op template must
mean what a reasonable user would assume without looking at any documentation.
Design Invariants
The above rules imply invariants, which are made explicit here. ParsedOp.
- You may not use an op field name or parameter name for more than one purpose.
- Treat all parameters supported by a driver adapter and it's op fields as a globally shared namespace, even if it is not. This avoids creating any confusion about what a parameter can be used for and how to use it for the right thing in the right place. For example, you may not use the parameter name `socket` in an op template to mean one thing and then use it at the driver adapter level to mean something different. However, if the meaning is congruent, a driver developer may choose to support some cross-cutting parameters at the activity level. These allowances are explicit, however, as each driver dictates what it will allow as activity parameters.
- Users may specify op payload fields within op params or activity params as fallback config sources in that order.
- IF a name is valid as an op field, it must also be valid as such when specified in op params.
- If a name is valid as an op field, it must also be valid as such when specified in activity params, within the scope of
ParsedOp - When an op field is found via op params or activity params, it may NOT be dynamic. If dynamic values are intended to be provided at a common layer in the workload, then bindings support this already.
- You must access non-payload params via Config-oriented methods.
- Op Templates contain op payload data and op configs (params, activity params).
- You must use only
ParsedOpgetters with "...Config..." names, such asgetConfigOr(String, Object, long)when accessing non-payload fields. - When a dynamic value is found via one of these calls, an error should be thrown, as configuration level data is not expected to be variant per-operation or cycle.
- The user must be warned when a required or optional config value is missing from op params (or activity params), but a value
of the same name is found in op payload fields.
- If rule #1 is followed, and names are unambiguous across the driver, then it is almost certainly a configuration error.
- When both an op payload field and a param field of the same name are defined through cascading configuration of param fields,
the local op payload field takes precedence.
- This is an extension of the param override rules which say that the closest (most local) value to an operation is the one that takes precedence.
- In practice, there will be no conflicts between direct static and dynamic fields, but there will be possibly between static or dynamic fields and parameters and activity params. If a user wants to promote an activity param as an override to existing op fields, template variables allow for this to happen gracefully. Otherwise, the order of precedence is 1) op fields 2) op params 3) activity params.
Op Payload Forms
Field values can come from multiple sources. These forms and any of their combinations are supported.Static Op Fields
Example:
op:
field1: value1
field2:
map3:
key4: value4
map5:
key6: value6
field7: false
field8: 8.8
As shown, any literal value of any valid YAML type, including structured values like lists or maps are accepted as
static op template values. A static value is any value which contains zero bind points at any level.
Dynamic Op Fields with Binding References
Example:
op:
field1: "{binding1}"
field2: "value is: {binding1}"
In this form, {binding1} is known as a binding reference, since the binding function is defined
elsewhere under the given name. The first field "field1" is specified with no leading nor trailing literals, and
is thus taken as a raw binding reference, meaning that it will not be converted to a String. The second,
named "field2", is what is known as a string template, and is syntactical sugar for a more complex binding
which concatenates static and dynamic parts together. In this form, object types produced by binding functions are
converted to string form before concatenation.
Note that a raw {binding1} value (without quotes) would be NOT be a binding reference, since YAML
is a superset of JSON. this means that {binding1} would be converted to a map or JSON object type
with invalid contents. This is warned about when detected as a null valued map key, although it also makes
null values invalid for ANY op template value.
Dynamic Op Fields with Binding Definitions
Example:
op:
field1: "{{NumberNameToString()}}"
field2: "value is: {{NumberNameToString()}}"
This form has exactly the same effect as the previous example as long as your bindings definitions included:
bindings:
binding1: NumberNameToString();
Dynamic Op Fields with Structure
Example:
field1:
k1: "{binding1}
k2: "literal value"
field2:
- "value3"
- "{binding4}"
- "a value: {binding5}"
- "{{NumberNameToString}}"
- "a value: {{NumberNameToString()}}"
This example combines the previous ones with structure and dynamic values. Both field1 and field2 are dynamic,
since each contains some dynamic value or template within. When field1 is accessed within a cycle, that cycle's value
will be used as the seed to generate equivalent structures with all the literal and dynamic elements inserted as
the template implies. As before, direct binding references like {binding4} will be inserted into the
structure with whatever type the binding definition produces, so if you want strings in them, ensure that you
configure your binding definitions thusly.
Op Template Params
Example:
params:
prepared: true
ops:
op1:
field1: value1
params:
prepared: false
The params section are the first layer of external configuration values that an op template can use to distinguish
op configuration parameters from op payload content.
Op Template Params are referenced when any of the getConfigOr(String, Object, long) or other ...Config...
getters are used (bypassing non-param fields). They are also accessed as a fallback when no static nor dynamic value is found
for a reference op template field. Unlike op fields, op params cascade from within the workload YAML from the document level,
down to each block and then down to each statement.
Activity Params
Example:
./nb run driver=... workload=... cl=LOCAL_QUORUM
When explicitly allowed by a driver adapter's configuration model, values like cl above can be seen as
another fallback source for configuration parameters. The ParsedOp implementation will automatically look
in the activity parameters if needed to find a missing configuration parameter, but this will only work if
the specific named parameter is allowed at the activity level.
-
Constructor Summary
ConstructorsConstructorDescriptionParsedOp(OpTemplate ot, io.nosqlbench.nb.api.config.standard.NBConfiguration activityCfg) Create a parsed command from an Op template.ParsedOp(OpTemplate opTemplate, io.nosqlbench.nb.api.config.standard.NBConfiguration activityCfg, List<Function<Map<String, Object>, Map<String, Object>>> preprocessors) Create a parsed command from an Op template. -
Method Summary
Modifier and TypeMethodDescriptionapply(long value) <FA,FE> LongFunction<FA> enhanceDefaultFunc(LongFunction<FA> func, String field, Class<FE> type, FE defaultFe, BiFunction<FA, FE, FA> combiner) Enhance aFunctionwith another required named field or function combiner OR a default value.<FA,FE extends Enum<FE>>
LongFunction<FA>enhanceEnum(LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance aFunctionwith an optional enum function IFF it is defined.<FA,FE> LongFunction<FA> enhanceFunc(LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance aFunctionwith a named required function, or throw an error.<FA,FE> LongFunction<FA> enhanceFuncOptionally(LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance aFunctionwith a named optional function IFF it exists.<FA,FE> Optional<LongFunction<FA>> enhanceOptionalDefaultFunc(Optional<LongFunction<FA>> func, String field, Class<FE> type, FE defaultFe, BiFunction<FA, FE, FA> combiner) <FA,FE> Optional<LongFunction<FA>> enhanceOptionalFuncOptionally(Optional<LongFunction<FA>> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) <T> TGet the named field value for a given long input.<V> LongFunction<V>getAsCachedFunctionOr(String fieldname, String defaultValue, Function<String, V> init) Get a LongFunction that first creates a LongFunction of String as ingetAsRequiredFunction(String, Class), but then applies the result and caches it for subsequent access.<V> LongFunction<V>getAsFunctionOr(String name, V defaultValue) Get a LongFunction which returns either the static value, the dynamic value, or the default value, in that order, depending on where it is found first.<V extends Enum<V>>
Optional<LongFunction<V>>getAsOptionalEnumFunction(String name, Class<V> type) <V> Optional<LongFunction<String>>getAsOptionalFunction(String name) <V> Optional<LongFunction<V>>getAsOptionalFunction(String name, Class<V> type) Get the op field as aLongFunctionLongFunction<? extends String>getAsRequiredFunction(String name) Get the op field as aLongFunctionof String.<V> LongFunction<V>getAsRequiredFunction(String name, Class<? extends V> type) Optional<io.nosqlbench.virtdata.core.templates.ParsedStringTemplate>getAsTemplate(String fieldname) <T> TgetConfigOr(String name, T defaultValue, long input) Works exactly likegetStaticConfigOr(String, Object), except that dynamic values at the op field level will be generated on a per-input basis.<E extends Enum<E>>
EgetEnumFromFieldOr(Class<E> enumClass, E defaultEnum, String fieldName) LongFunction<?>Get theLongFunctionwhich is used to resolve a dynamic field value.getName()getOptionalEnumFromField(Class<E> enumclass, String fieldName) <T> Optional<T>getOptionalStaticConfig(String name, Class<T> type) <T> Optional<T>getOptionalStaticValue(String field, Class<T> classOfT) Return an optional value for the named field.getOptionalTypeAndTargetEnum(Class<E> enumclass, Class<V> valueClass) getOptionalTypeAndTargetEnum(Class<E> enumclass, Class<V> valueClass, String alternateTypeField, String alternateValueField) intgetSize()getStaticConfig(String name, Class<String> clazz) <T> TgetStaticConfigOr(String name, T defaultValue) Get the specified parameter by the user using the defined field which is closest to the op template.<T> TgetStaticValue(String field) Get the static value for the provided name, cast to the required type, where the type is inferred from the calling context.<T> TgetStaticValue(String field, Class<T> classOfT) Get the static value for the provided name, cast to the required type.<T> TgetStaticValueOr(String name, T defaultValue) Get the named static field value, or return the provided default, but throw an exception if the named field is dynamic.io.nosqlbench.engine.api.templating.ParsedTemplateMap<E extends Enum<E>,V>
io.nosqlbench.engine.api.templating.TypeAndTarget<E,V> getTypeAndTarget(Class<E> enumclass, Class<V> valueClass) <E extends Enum<E>,V>
io.nosqlbench.engine.api.templating.TypeAndTarget<E,V> getTypeAndTarget(Class<E> enumclass, Class<V> valueclass, String tname, String vname) getTypeAndTargetFromEnum(Class<E> enumclass, Class<V> valueClass) Given an enum of any type, return the enum value which is found in any of the field names of the op template, ignoring case and any non-word characters.Class<?>getValueType(String fieldname) booleanbooleanbooleanbooleanisDefinedAll(String... fields) convenience method for conjugatingisDefined(String)with ANDbooleanbooleanbooleanbooleanisUndefined(String field) Inverse ofisDefined(String), provided for clarify in some situationsnewArrayBinder(String... fields) newArrayBinder(List<String> fields) newArrayBinderFromBindPoints(List<io.nosqlbench.virtdata.core.templates.BindPoint> bindPoints) newListBinder(String... fields) newListBinder(List<String> fields) newOrderedMapBinder(String... fields) parseStaticCmdMap(String key, String mainField) <T> Optional<T>takeOptionalStaticValue(String field, Class<T> classOfT) <T> TtakeStaticConfigOr(String name, T defaultValue) Get the parameter value from a static op template field OR any of the provided optional sources of op template values, including the activity parameterstoString()
-
Constructor Details
-
ParsedOp
Create a parsed command from an Op template.- Parameters:
ot- An OpTemplate representing an operation to be performed in a native driver.activityCfg- The activity configuration, used for reading config parameters
-
ParsedOp
public ParsedOp(OpTemplate opTemplate, io.nosqlbench.nb.api.config.standard.NBConfiguration activityCfg, List<Function<Map<String, Object>, Map<String, Object>>> preprocessors) Create a parsed command from an Op template. This version is exactly like(OpTemplate,NBConfiguration)except that it allows preprocessors. Preprocessors are all applied to the the op template before it is applied to the parsed command fields, allowing you to combine or destructure fields from more tha one representation into a single canonical representation for processing.- Parameters:
opTemplate- The OpTemplate as provided by a user via YAML, JSON, or API (data structure)activityCfg- The activity configuration, used to resolve nested config parameterspreprocessors- Map->Map transformers.
-
-
Method Details
-
getName
-
getTemplateMap
public io.nosqlbench.engine.api.templating.ParsedTemplateMap getTemplateMap() -
apply
- Specified by:
applyin interfaceLongFunction<Map<String,?>>
-
isDynamic
- Specified by:
isDynamicin interfaceio.nosqlbench.nb.api.config.fieldreaders.DynamicFieldReader
-
isStatic
- Parameters:
field- The field name to look for in the static field map.- Returns:
- true if and only if the named field is present in the static field map.
-
isStatic
-
isDefined
- Specified by:
isDefinedin interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Parameters:
fields- Names of fields to look for in the static field map.- Returns:
- true if and only if all provided field names are present in the static field map.
-
getStaticValue
Get the static value for the provided name, cast to the required type.- Specified by:
getStaticValuein interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Type Parameters:
T- The parameter type of the return type, used at compile time only to qualify asserted return type- Parameters:
field- Name of the field to getclassOfT- The type of the field to return. If actual type is not compatible to a cast to this type, then a casting error will be thrown.- Returns:
- A value of type T, or null
-
getStaticValue
Get the static value for the provided name, cast to the required type, where the type is inferred from the calling context.- Specified by:
getStaticValuein interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Type Parameters:
T- The parameter type of the return type. used at compile time only to quality return type.- Parameters:
field- Name of the field to get- Returns:
- A value of type T, or null
-
getAsTemplate
-
getStaticValueOr
Get the named static field value, or return the provided default, but throw an exception if the named field is dynamic.- Specified by:
getStaticValueOrin interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Type Parameters:
T- The type of the field to return.- Parameters:
name- The name of the field value to return.defaultValue- A value to return if the named value is not present in static nor dynamic fields.- Returns:
- The value
- Throws:
RuntimeException- if the field name is only present in the dynamic fields.
-
getStaticConfigOr
Get the specified parameter by the user using the defined field which is closest to the op template. This is the standard way of getting parameter values which can be specified at the op template, op param, or activity level.- Type Parameters:
T- The type of the value to return- Parameters:
name- The name of the configuration paramdefaultValue- the default value to return if the value is not defined anywhere in (op fields, op params, activity params)- Returns:
- A configuration value
- Throws:
io.nosqlbench.nb.api.config.standard.NBConfigError- if the named field is defined dynamically, as in this case, it is presumed that the parameter is not supported unless it is defined statically.
-
takeStaticConfigOr
Get the parameter value from a static op template field OR any of the provided optional sources of op template values, including the activity parameters- Type Parameters:
T- The type of the field- Parameters:
name- The config field namedefaultValue- The default value, if the field is not defined in the op template nor the activity params- Returns:
- The config value.
-
getStaticConfig
-
getOptionalStaticConfig
-
getConfigOr
Works exactly likegetStaticConfigOr(String, Object), except that dynamic values at the op field level will be generated on a per-input basis. This is a shortcut method for allowing configuration values to be accessed dynamically where it makes sense. -
getOptionalStaticValue
Return an optional value for the named field. This is anOptionalform ofgetStaticValue(java.lang.String, java.lang.Class<T>).- Specified by:
getOptionalStaticValuein interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Type Parameters:
T- The parameter type of the return- Parameters:
field- Name of the field to getclassOfT- The type of field to return. If the actual type is not compatible to a cast to this type, then a casting error will be thrown.- Returns:
- An optional value, empty unless the named value is defined in the static field map.
-
takeOptionalStaticValue
-
get
Get the named field value for a given long input. This uses parameter type inference -- The casting to the return type will be based on the type of any assignment or casting on the caller's side. Thus, if the actual type is not compatable to a cast to the needed return type, a casting error will be thrown.- Specified by:
getin interfaceio.nosqlbench.nb.api.config.fieldreaders.DynamicFieldReader- Type Parameters:
T- The parameter type of the returned value. Inferred from usage context.- Parameters:
field- The name of the field to get.input- The seed value, or cycle value for which to generate the value.- Returns:
- The value.
-
getDefinedNames
- Returns:
- a set of names which are defined, whether in static fields or dynamic fields
-
getAsRequiredFunction
Get the op field as aLongFunctionof String. This is a convenience form forgetAsRequiredFunction(String, Class)- Parameters:
name- The field name which must be defined as static or dynamic- Returns:
- A function which can provide the named field value
-
getAsOptionalFunction
Get the op field as aLongFunction- Parameters:
name- The field name which must be defined as static or dynamictype- The value type which the field must be assignable to- Returns:
- A function which can provide a value for the given name and type
-
getAsOptionalEnumFunction
public <V extends Enum<V>> Optional<LongFunction<V>> getAsOptionalEnumFunction(String name, Class<V> type) -
getAsOptionalFunction
-
getAsRequiredFunction
-
getAsFunctionOr
Get a LongFunction which returns either the static value, the dynamic value, or the default value, in that order, depending on where it is found first.- Specified by:
getAsFunctionOrin interfaceio.nosqlbench.nb.api.config.fieldreaders.DynamicFieldReader- Type Parameters:
V- The type of value to return- Parameters:
name- The param name for the valuedefaultValue- The default value to provide the value is not defined for static nor dynamic- Returns:
- A
LongFunctionof type V
-
getAsCachedFunctionOr
public <V> LongFunction<V> getAsCachedFunctionOr(String fieldname, String defaultValue, Function<String, V> init) Get a LongFunction that first creates a LongFunction of String as ingetAsRequiredFunction(String, Class), but then applies the result and caches it for subsequent access. This relies onObjectCacheinternally.- Type Parameters:
V- The type of object to return- Parameters:
fieldname- The name of the field which could contain a static or dynamic valuedefaultValue- The default value to use in the init function if the fieldname is not defined as static nor dynamicinit- A function to apply to the value to produce the product type- Returns:
- A caching function which chains to the init function, with caching
-
isDefined
- Specified by:
isDefinedin interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Parameters:
field- The requested field name- Returns:
- true if the named field is defined as static or dynamic
-
isUndefined
Inverse ofisDefined(String), provided for clarify in some situations- Parameters:
field- The field name- Returns:
- true if the named field is defined neither as static nor as dynamic
-
isDefined
- Specified by:
isDefinedin interfaceio.nosqlbench.nb.api.config.fieldreaders.StaticFieldReader- Parameters:
field- The requested field nametype- The required type of the field value- Returns:
- true if the named field is defined as static or dynamic and the value produced can be assigned to the specified type
-
isDefinedAll
convenience method for conjugatingisDefined(String)with AND- Parameters:
fields- The fields which should be defined as either static or dynamic- Returns:
- true if all specified fields are defined as static or dynamic
-
newListBinder
- Parameters:
fields- The ordered field names for which theListBinderwill be created- Returns:
- a new
ListBinderwhich can produce aListof Objects from a long input.
-
newListBinder
- Parameters:
fields- The ordered field names for which theListBinderwill be created- Returns:
- a new
ListBinderwhich can produce aListof Objects from a long input.
-
newOrderedMapBinder
- Parameters:
fields- The ordered field names for which theOrderedMapBinderwill be created- Returns:
- a new
OrderedMapBinderwhich can produce aMapof String to Objects from a long input.
-
newArrayBinder
- Parameters:
fields- The ordered field names for which theArrayBinderwill be created- Returns:
- a new
ArrayBinderwhich can produce aObjectarray from a long input.
-
newArrayBinder
- Parameters:
fields- The ordered field names for which theArrayBinderwill be created- Returns:
- a new
ArrayBinderwhich can produce aObjectarray from a long input.
-
newArrayBinderFromBindPoints
public LongFunction<Object[]> newArrayBinderFromBindPoints(List<io.nosqlbench.virtdata.core.templates.BindPoint> bindPoints) - Parameters:
bindPoints- TheBindPoints for which theArrayBinderwill be created- Returns:
- a new
ArrayBinderwhich can produce aObjectarray from a long input.
-
getMapper
Get theLongFunctionwhich is used to resolve a dynamic field value.- Parameters:
field- The field name for a dynamic parameter- Returns:
- The mapping function
-
getSize
public int getSize()- Returns:
- the logical map size, including all static and dynamic fields
-
getValueType
-
getTypeAndTargetFromEnum
public <E extends Enum<E>,V> Optional<io.nosqlbench.engine.api.templating.TypeAndTarget<E,V>> getTypeAndTargetFromEnum(Class<E> enumclass, Class<V> valueClass) Given an enum of any type, return the enum value which is found in any of the field names of the op template, ignoring case and any non-word characters. This is useful for matching op templates to op types where the presence of a field determines the type. Further, if there are multiple matching names, anOpConfigErroris thrown to avoid possible ambiguity.- Type Parameters:
E- Generic type for the enum class- Parameters:
enumclass- The enum class for matching values- Returns:
- Optionally, an enum value which matches, or
Optional.empty() - Throws:
io.nosqlbench.nb.api.errors.OpConfigError- if more than one field matches
-
getOptionalTypeAndTargetEnum
-
getOptionalTypeAndTargetEnum
-
getTypeAndTarget
-
getTypeAndTarget
-
getOptionalEnumFromField
-
getEnumFromFieldOr
-
enhanceDefaultFunc
public <FA,FE> LongFunction<FA> enhanceDefaultFunc(LongFunction<FA> func, String field, Class<FE> type, FE defaultFe, BiFunction<FA, FE, FA> combiner) Enhance a
Functionwith another required named field or function combiner OR a default value.- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuedefaultFe- The default value of the field, if none is providedcombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- an enhanced function
-
enhanceFunc
public <FA,FE> LongFunction<FA> enhanceFunc(LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance a
Functionwith a named required function, or throw an error.- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuecombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- a version of the base function, optionally enhanced
-
enhanceFuncOptionally
public <FA,FE> LongFunction<FA> enhanceFuncOptionally(LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance a
Functionwith a named optional function IFF it exists.- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuecombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- a version of the base function, optionally enhanced
-
enhanceOptionalFuncOptionally
public <FA,FE> Optional<LongFunction<FA>> enhanceOptionalFuncOptionally(Optional<LongFunction<FA>> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance an
OptionalFunctionwith an optional named field or value combiner, IFF both functions are defined.- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuecombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- the enhanced optional function
-
enhanceOptionalDefaultFunc
public <FA,FE> Optional<LongFunction<FA>> enhanceOptionalDefaultFunc(Optional<LongFunction<FA>> func, String field, Class<FE> type, FE defaultFe, BiFunction<FA, FE, FA> combiner) Enhance an
OptionalFunctionwith a named field or function combiner OR a default value, IFF the base function is present.Create a required function for the specified field and default value, IFF the main function is present. The base type of the function remains the same, and if present, will be extended with the required field value or function in the provided combiner.
- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuedefaultFe- The default value of the field, if none is providedcombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- the enhanced optional base function
-
enhanceEnum
public <FA,FE extends Enum<FE>> LongFunction<FA> enhanceEnum(LongFunction<FA> func, String field, Class<FE> type, BiFunction<FA, FE, FA> combiner) Enhance a
Functionwith an optional enum function IFF it is defined.- Type Parameters:
FA- The base function result typeFE- The enhancer function result type- Parameters:
func- The base functionfield- The field name to derive the named enhancer function fromtype- The type of the field valuecombiner- ABiFunctionwhich applies the field or function combiner to the base function- Returns:
- an (optionally) enhanced base function
-
parseStaticCmdMap
-
toString
-