001/*
002 * Copyright (c) 2015-2020, Oracle and/or its affiliates. All rights reserved.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.tribuo.data.columnar;
018
019import com.oracle.labs.mlrg.olcut.config.Configurable;
020import com.oracle.labs.mlrg.olcut.provenance.ConfiguredObjectProvenance;
021import com.oracle.labs.mlrg.olcut.provenance.Provenancable;
022import org.tribuo.Output;
023import org.tribuo.OutputFactory;
024
025import java.util.Optional;
026
027/**
028 * An interface that will take the response field and produce an {@link Output}.
029 */
030public interface ResponseProcessor<T extends Output<T>> extends Configurable, Provenancable<ConfiguredObjectProvenance> {
031
032    /**
033     * Gets the OutputFactory this ResponseProcessor uses.
034     * @return The output factory.
035     */
036    public OutputFactory<T> getOutputFactory();
037
038    /**
039     * Gets the field name this ResponseProcessor uses.
040     * @return The field name.
041     */
042    public String getFieldName();
043
044    /**
045     * @deprecated Response processors should be immutable; downstream objects assume that they are
046     * Set the field name this ResponseProcessor uses.
047     * @param fieldName The field name.
048     *
049     */
050    @Deprecated()
051    public void setFieldName(String fieldName);
052
053    /**
054     * Returns Optional.empty() if it failed to process out a response.
055     * @param value The value to process.
056     * @return The response value if found.
057     */
058    public Optional<T> process(String value);
059}