All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.eclipse.ditto.placeholders.PipelineElementVisitor Maven / Gradle / Ivy

There is a newer version: 3.6.2
Show newest version
/*
 * Copyright (c) 2021 Contributors to the Eclipse Foundation
 *
 * See the NOTICE file(s) distributed with this work for additional
 * information regarding copyright ownership.
 *
 * This program and the accompanying materials are made available under the
 * terms of the Eclipse Public License 2.0 which is available at
 * http://www.eclipse.org/legal/epl-2.0
 *
 * SPDX-License-Identifier: EPL-2.0
 */
package org.eclipse.ditto.placeholders;

import java.util.function.Function;
import java.util.function.Supplier;

/**
 * Visitor to evaluate pipeline elements.
 *
 * @param  type of results.
 */
public interface PipelineElementVisitor {

    /**
     * Evaluate a resolved value.
     *
     * @param value the resolved value.
     * @return the result.
     */
    T resolved(String value);

    /**
     * Evaluate the unique pipeline element signifying failed resolution.
     *
     * @return the result.
     */
    T unresolved();

    /**
     * Evaluate the unique pipeline element signifying deletion of the whole string containing the pipeline.
     *
     * @return the result.
     */
    T deleted();

    /**
     * Builder of a visitor to evaluate pipeline elements.
     *
     * @param  the type of results.
     */
    interface Builder {

        /**
         * Create the visitor.
         *
         * @return the visitor.
         */
        PipelineElementVisitor build();

        /**
         * Set callback to handle resolved values.
         *
         * @param onResolution what to do on resolved values.
         * @return this builder.
         */
        Builder resolved(Function onResolution);

        /**
         * Set callback to handle resolution failure.
         *
         * @param onIrresolution what to do on resolution failure.
         * @return this builder.
         */
        Builder unresolved(Supplier onIrresolution);

        /**
         * Set callback to handle deletion.
         *
         * @param onDeletion what to do when deletion is signalled.
         * @return this builder.
         */
        Builder deleted(Supplier onDeletion);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy