connectors/rocketmq-connect-doris/src/main/java/org/apache/rocketmq/connect/doris/util/ExpressionBuilder.java [19:150]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class ExpressionBuilder {

    /**
     * A functional interface for anything that can be appended to an expression builder.
     * This makes use of double-dispatch to allow implementations to customize the behavior,
     * yet have callers not care about the differences in behavior.
     */
    @FunctionalInterface
    public interface Expressable {

        /**
         * Append this object to the specified builder.
         *
         * @param builder   the builder to use; may not be null
         * @param useQuotes whether quotes should be used for this object
         */
        void appendTo(
                ExpressionBuilder builder,
                boolean useQuotes
        );

        /**
         * Append this object to the specified builder.
         *
         * @param builder   the builder to use; may not be null
         * @param useQuotes whether quotes should be used for this object
         */
        default void appendTo(
                ExpressionBuilder builder,
                QuoteMethod useQuotes
        ) {
            switch (useQuotes) {
                case ALWAYS:
                    appendTo(builder, true);
                    break;
                case NEVER:
                default:
                    // do nothing
                    break;
            }
        }
    }

    /**
     * A functional interface for a transformation that an expression builder might use when
     * appending one or more other objects.
     *
     * @param <T> the type of object to transform before appending.
     */
    @FunctionalInterface
    public interface Transform<T> {
        void apply(
                ExpressionBuilder builder,
                T input
        );
    }

    /**
     * A fluent API interface returned by the {@link ExpressionBuilder#appendList()} method that
     * allows a caller to easily define a custom delimiter to be used between items in the list,
     * an optional transformation that should be applied to each item in the list, and the
     * items in the list. This is very handle when the number of items is not known a priori.
     *
     * @param <T> the type of object to be appended to the expression builder
     */
    public interface ListBuilder<T> {

        /**
         * Define the delimiter to appear between items in the list. If not specified, a comma
         * is used as the default delimiter.
         *
         * @param delimiter the delimiter; may not be null
         * @return this builder to enable methods to be chained; never null
         */
        ListBuilder<T> delimitedBy(String delimiter);

        /**
         * Define a {@link Transform} that should be applied to every item in the list as it is
         * appended.
         *
         * @param transform the transform; may not be null
         * @param <R>       the type of item to be transformed
         * @return this builder to enable methods to be chained; never null
         */
        <R> ListBuilder<R> transformedBy(Transform<R> transform);

        /**
         * Append to this list all of the items in the specified {@link Iterable}.
         *
         * @param objects the objects to be appended to the list
         * @return this builder to enable methods to be chained; never null
         */
        ExpressionBuilder of(Iterable<? extends T> objects);

        /**
         * Append to this list all of the items in the specified {@link Iterable} objects.
         *
         * @param objects1 the first collection of objects to be added to the list
         * @param objects2 a second collection of objects to be added to the list
         * @return this builder to enable methods to be chained; never null
         */
        default ExpressionBuilder of(Iterable<? extends T> objects1, Iterable<? extends T> objects2) {
            of(objects1);
            return of(objects2);
        }

        /**
         * Append to this list all of the items in the specified {@link Iterable} objects.
         *
         * @param objects1 the first collection of objects to be added to the list
         * @param objects2 a second collection of objects to be added to the list
         * @param objects3 a third collection of objects to be added to the list
         * @return this builder to enable methods to be chained; never null
         */
        default ExpressionBuilder of(
                Iterable<? extends T> objects1,
                Iterable<? extends T> objects2,
                Iterable<? extends T> objects3
        ) {
            of(objects1);
            of(objects2);
            return of(objects3);
        }
    }

    /**
     * Get a {@link Transform} that will surround the inputs with quotes.
     *
     * @return the transform; never null
     */
    public static Transform<String> quote() {
        return (builder, input) -> builder.appendColumnName(input);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



connectors/rocketmq-connect-jdbc/src/main/java/org/apache/rocketmq/connect/jdbc/util/ExpressionBuilder.java [21:75]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
public class ExpressionBuilder {

    @FunctionalInterface
    public interface Expressable {

        void appendTo(
            ExpressionBuilder builder,
            boolean useQuotes
        );
        default void appendTo(
            ExpressionBuilder builder,
            QuoteMethod useQuotes
        ) {
            switch (useQuotes) {
                case ALWAYS:
                    appendTo(builder, true);
                    break;
                case NEVER:
                default:
                    // do nothing
                    break;
            }
        }
    }

    @FunctionalInterface
    public interface Transform<T> {
        void apply(
            ExpressionBuilder builder,
            T input
        );
    }
    public interface ListBuilder<T> {
        ListBuilder<T> delimitedBy(String delimiter);
        <R> ListBuilder<R> transformedBy(Transform<R> transform);

        ExpressionBuilder of(Iterable<? extends T> objects);
        default ExpressionBuilder of(Iterable<? extends T> objects1, Iterable<? extends T> objects2) {
            of(objects1);
            return of(objects2);
        }

        default ExpressionBuilder of(
                Iterable<? extends T> objects1,
                Iterable<? extends T> objects2,
                Iterable<? extends T> objects3
        ) {
            of(objects1);
            of(objects2);
            return of(objects3);
        }
    }

    public static Transform<String> quote() {
        return (builder, input) -> builder.appendColumnName(input);
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



