Class FieldResponseProcessor<T extends Output<T>>
java.lang.Object
org.tribuo.data.columnar.processors.response.FieldResponseProcessor<T>
- All Implemented Interfaces:
com.oracle.labs.mlrg.olcut.config.Configurable
,com.oracle.labs.mlrg.olcut.provenance.Provenancable<com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance>
,ResponseProcessor<T>
public class FieldResponseProcessor<T extends Output<T>>
extends Object
implements ResponseProcessor<T>
A response processor that returns the value(s) in a given (set of) fields.
We support specifying field names and default values both singly through fieldName
and defaultValue
and in a list through fieldNames
and defaultValues
. The constructors and configuration preprocessing
have differing behaviors based on which fields are populated:
-
fieldNames
anddefaultValues
are both populated and the same length: fieldNames[i]'s defaultValue is defaultValues[i] -
fieldNames
anddefaultValue
are both populated: defaultValue is broadcast across all fieldNames -
fieldName
anddefaultValue
are both populated: fieldNames[0] == fieldName, defaultValues[0] == defaultValue
-
Constructor Summary
ConstructorDescriptionFieldResponseProcessor
(String fieldName, String defaultValue, OutputFactory<T> outputFactory) Constructs a response processor which passes the field value through the output factory.FieldResponseProcessor
(List<String> fieldNames, String defaultValue, OutputFactory<T> outputFactory) Constructs a response processor which passes the field value through the output factory.FieldResponseProcessor
(List<String> fieldNames, List<String> defaultValues, OutputFactory<T> outputFactory) Constructs a response processor which passes the field value through the output factory.FieldResponseProcessor
(List<String> fieldNames, List<String> defaultValues, OutputFactory<T> outputFactory, boolean displayField) Constructs a response processor which passes the field value through the output factory.FieldResponseProcessor
(List<String> fieldNames, List<String> defaultValues, OutputFactory<T> outputFactory, boolean displayField, boolean uppercase) Constructs a response processor which passes the field value through the output factory. -
Method Summary
Modifier and TypeMethodDescriptionDeprecated.Gets the field names this ResponseProcessor uses.Gets the OutputFactory this ResponseProcessor uses.com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance
void
Deprecated.Returns Optional.empty() if it failed to process out a response.This method has a default implementation for backwards compatibility with Tribuo 4.0 and 4.1.void
setFieldName
(String fieldName) Deprecated.toString()
-
Constructor Details
-
FieldResponseProcessor
public FieldResponseProcessor(String fieldName, String defaultValue, OutputFactory<T> outputFactory) Constructs a response processor which passes the field value through the output factory. Uppercases the value before generating the output.- Parameters:
fieldName
- The field to read.defaultValue
- The default value to extract if it's not found.outputFactory
- The output factory to use.
-
FieldResponseProcessor
public FieldResponseProcessor(List<String> fieldNames, String defaultValue, OutputFactory<T> outputFactory) Constructs a response processor which passes the field value through the output factory. Uppercases the value before generating the output.- Parameters:
fieldNames
- The fields to read.defaultValue
- The default value to extract if it's not found.outputFactory
- The output factory to use.
-
FieldResponseProcessor
public FieldResponseProcessor(List<String> fieldNames, List<String> defaultValues, OutputFactory<T> outputFactory) Constructs a response processor which passes the field value through the output factory. fieldNames and defaultValues must be the same length. Uppercases the value before generating the output.- Parameters:
fieldNames
- The field to read.defaultValues
- The default value to extract if it's not found.outputFactory
- The output factory to use.
-
FieldResponseProcessor
public FieldResponseProcessor(List<String> fieldNames, List<String> defaultValues, OutputFactory<T> outputFactory, boolean displayField) Constructs a response processor which passes the field value through the output factory. fieldNames and defaultValues must be the same length. Uppercases the value before generating the output.- Parameters:
fieldNames
- The field to read.defaultValues
- The default value to extract if it's not found.outputFactory
- The output factory to use.displayField
- whether to include field names in the generated labels.
-
FieldResponseProcessor
public FieldResponseProcessor(List<String> fieldNames, List<String> defaultValues, OutputFactory<T> outputFactory, boolean displayField, boolean uppercase) Constructs a response processor which passes the field value through the output factory. fieldNames and defaultValues must be the same length.- Parameters:
fieldNames
- The field to read.defaultValues
- The default value to extract if it's not found.outputFactory
- The output factory to use.displayField
- Whether to include field names in the generated output.uppercase
- Whether to uppercase the value before generating the output.
-
-
Method Details
-
postConfig
public void postConfig()- Specified by:
postConfig
in interfacecom.oracle.labs.mlrg.olcut.config.Configurable
-
setFieldName
Deprecated.- Specified by:
setFieldName
in interfaceResponseProcessor<T extends Output<T>>
- Parameters:
fieldName
- The field name.
-
getOutputFactory
Description copied from interface:ResponseProcessor
Gets the OutputFactory this ResponseProcessor uses.- Specified by:
getOutputFactory
in interfaceResponseProcessor<T extends Output<T>>
- Returns:
- The output factory.
-
getFieldName
Deprecated.- Specified by:
getFieldName
in interfaceResponseProcessor<T extends Output<T>>
- Returns:
- The field name.
-
process
Deprecated.- Specified by:
process
in interfaceResponseProcessor<T extends Output<T>>
- Parameters:
value
- The value to process.- Returns:
- The response value if found.
-
process
Description copied from interface:ResponseProcessor
Returns Optional.empty() if it failed to process out a response.This method has a default implementation for backwards compatibility with Tribuo 4.0 and 4.1. This method should be overridden by code which depends on newer versions of Tribuo. The default implementation will be removed when the deprecated members are removed. Unless is is overridden it will throw anIllegalArgumentException
when called with multiple values.- Specified by:
process
in interfaceResponseProcessor<T extends Output<T>>
- Parameters:
values
- The value to process.- Returns:
- The response values if found.
-
getFieldNames
Description copied from interface:ResponseProcessor
Gets the field names this ResponseProcessor uses.- Specified by:
getFieldNames
in interfaceResponseProcessor<T extends Output<T>>
- Returns:
- The field names.
-
toString
-
getProvenance
public com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance getProvenance()
-