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

velocity.endpoint-builder.vm Maven / Gradle / Ivy

The newest version!
## ---------------------------------------------------------------------------
## Licensed to the Apache Software Foundation (ASF) under one or more
## contributor license agreements.  See the NOTICE file distributed with
## this work for additional information regarding copyright ownership.
## The ASF licenses this file to You under the Apache License, Version 2.0
## (the "License"); you may not use this file except in compliance with
## the License.  You may obtain a copy of the License at
##
##      http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
## ---------------------------------------------------------------------------
#set( $newline="
")
#set( $builderName = $componentName + "EndpointBuilder" )
/* Generated by camel build tools - do NOT edit this file! */
/*
 * Licensed to the Apache Software Foundation (ASF) under one or more
 * contributor license agreements.  See the NOTICE file distributed with
 * this work for additional information regarding copyright ownership.
 * The ASF licenses this file to You under the Apache License, Version 2.0
 * (the "License"); you may not use this file except in compliance with
 * the License.  You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.apache.camel.builder.endpoint.dsl;

import java.util.*;
import java.util.concurrent.*;
import java.util.function.*;
import java.util.stream.*;
import javax.annotation.processing.Generated;
import org.apache.camel.builder.EndpointConsumerBuilder;
import org.apache.camel.builder.EndpointProducerBuilder;
import org.apache.camel.builder.endpoint.AbstractEndpointBuilder;

${mojo.javadoc("", $model.description + $newline + $newline + "Generated by camel build tools - do NOT edit this file!")}
@Generated("${generatorClass}")
public interface ${builderName}Factory {

#macro( process $option $cpb $advanced $target )
    #if( $option.kind != "path" )
        #set( $label = $option.label )
        #if( !$label )
            #set( $label = "" )
        #end
        #if( (($advanced && $label.contains("advanced")) || (!$advanced && !$label.contains("advanced")))
                && ( $label.contains("producer") && ($cpb == 1 || $model.producerOnly) || !$label.contains("producer") )
                && ( $label.contains("consumer") && ($cpb == 0 || $model.consumerOnly) || !$label.contains("consumer") ) )
            #if( $option.multiValue )
                #set( $javadoc = $mojo.createBaseDescription($option, "parameter", false, $newline
                    + "The option is a: " + $option.javaType.replace("<", "<").replace(">", ">")
                    + " type.") )
                #set( $javadoc = $javadoc + $newline + $newline
                    + "@param key the option key" + $newline
                    + "@param value the option value" + $newline
                    + "@return the dsl builder" + $newline )
        ${mojo.javadoc("        ", $javadoc)}
                #if( $option.deprecated )
        @Deprecated
                #end
        default $target ${option.name}(String key, Object value) {
            doSetMultiValueProperty("${option.name}", "${option.prefix}" + key, value);
            return this;
        }
                #set( $javadoc = $mojo.createBaseDescription($option, "parameter", false, $newline
                    + "The option is a: " + $option.javaType.replace("<", "<").replace(">", ">")
                    + " type.") )
                #set( $javadoc = $javadoc + $newline + $newline
                    + "@param values the values" + $newline
                    + "@return the dsl builder" + $newline )
        ${mojo.javadoc("        ", $javadoc)}
                #if( $option.deprecated )
        @Deprecated
                #end
        default $target ${option.name}(Map values) {
            doSetMultiValueProperties("${option.name}", "${option.prefix}", values);
            return this;
        }
            #else
                #set( $javadoc = $mojo.createBaseDescription($option, "parameter", false, $newline
                    + "The option is a: " + $option.javaType.replace("<", "<").replace(">", ">")
                    + " type.") )
                #set( $javadoc = $javadoc + $newline + $newline
                    + "@param " + $option.name + " the value to set" + $newline
                    + "@return the dsl builder" + $newline )
        ${mojo.javadoc("        ", $javadoc)}
                #if( $option.deprecated )
        @Deprecated
                #end
        default $target ${option.name}(${mojo.optionJavaType($option)} ${option.name}) {
            doSetProperty("${option.name}", ${option.name});
            return this;
        }
                #if( $option.javaType != "java.lang.String" )
                    #set( $javadoc = $mojo.createBaseDescription($option, "parameter", false, $newline
                        + "The option will be converted to a " + $option.javaType.replace("<", "<").replace(">", ">")
                        + " type.") )
                    #set( $javadoc = $javadoc + $newline + $newline
                        + "@param " + $option.name + " the value to set" + $newline
                        + "@return the dsl builder" + $newline )
        ${mojo.javadoc("        ", $javadoc)}
                    #if( $option.deprecated )
        @Deprecated
                    #end
        default $target ${option.name}(String ${option.name}) {
            doSetProperty("${option.name}", ${option.name});
            return this;
        }
                #end
            #end
        #end
    #end
#end
#set( $advanced = false )
#foreach( $opt in $model.endpointOptions )
    #if( $opt.label && $opt.label.contains("advanced") )
        #set( $advanced = true )
    #end
#end
#if( !$model.producerOnly && !$model.consumerOnly )
    #set( $consumerName = $builderName.replace("Endpoint", "EndpointConsumer") )
    #set( $producerName = $builderName.replace("Endpoint", "EndpointProducer") )
    /**
     * Builder for endpoint consumers for the ${model.title} component.
     */
    public interface ${consumerName}
            extends
                EndpointConsumerBuilder {
    #if( $advanced )
        default Advanced${consumerName} advanced() {
            return (Advanced${consumerName}) this;
        }
    #end
    #foreach( $option in $model.endpointOptions )
        #process( $option 0 false "$consumerName" )
    #end
    }

    #if( $advanced )
    /**
     * Advanced builder for endpoint consumers for the ${model.title} component.
     */
    public interface Advanced${consumerName}
            extends
                EndpointConsumerBuilder {
        default ${consumerName} basic() {
            return (${consumerName}) this;
        }
    #foreach( $option in $model.endpointOptions )
        #process( $option 0 true "Advanced${consumerName}" )
    #end
    }

    #end
    /**
     * Builder for endpoint producers for the ${model.title} component.
     */
    public interface ${producerName}
            extends
                EndpointProducerBuilder {
    #if( $advanced )
        default Advanced${producerName} advanced() {
            return (Advanced${producerName}) this;
        }
    #end

    #foreach( $option in $model.endpointOptions )
        #process( $option 1 false "${producerName}" )
    #end
    }

    #if( $advanced )
    /**
     * Advanced builder for endpoint producers for the ${model.title} component.
     */
    public interface Advanced${producerName} extends EndpointProducerBuilder {
        default ${producerName} basic() {
            return (${producerName}) this;
        }

    #foreach( $option in $model.endpointOptions )
        #process( $option 1 true "Advanced${producerName}" )
    #end
    }

    #end
#end
    /**
     * Builder for endpoint for the ${model.title} component.
     */
    public interface ${builderName}
    #if( $model.consumerOnly )
            extends
                EndpointConsumerBuilder {
    #elseif( $model.producerOnly )
            extends
                EndpointProducerBuilder {
    #else
            extends
                ${consumerName},
                ${producerName} {
    #end
    #if( $advanced )
        default Advanced${builderName} advanced() {
            return (Advanced${builderName}) this;
        }
    #end

    #foreach( $option in $model.endpointOptions )
        #process( $option 2 false "${builderName}" )
    #end
    }

    #if( $advanced )
    /**
     * Advanced builder for endpoint for the ${model.title} component.
     */
    public interface Advanced${builderName}
        #if( $model.consumerOnly )
            extends
                EndpointConsumerBuilder {
        #elseif( $model.producerOnly )
            extends
                EndpointProducerBuilder {
        #else
            extends
                Advanced${consumerName},
                Advanced${producerName} {
        #end
        default ${builderName} basic() {
            return (${builderName}) this;
        }

    #foreach( $option in $model.endpointOptions )
        #process( $option 2 true "Advanced${builderName}" )
    #end
    }

    #end
    public interface ${componentName}Builders {
    #if( !$model.endpointHeaders.empty )
        #set( $javadoc = $mojo.getMainDescription($model, false) + $newline + $newline
                            + "@return the dsl builder for the headers' name." + $newline )
        ${mojo.javadoc("        ", $javadoc)}
        #if( $model.deprecated )
        @Deprecated
        #end
        default ${componentName}HeaderNameBuilder ${mojo.camelCaseLower($model.scheme)}() {
            return ${componentName}HeaderNameBuilder.INSTANCE;
        }
    #end
    #if( $aliases.size() == 1 )
        #set( $javadoc = $mojo.getMainDescription($model, true) + $newline + $newline
                            + "@param path " + $mojo.pathParameterJavaDoc($model) + $newline
                            + "@return the dsl builder" + $newline )
        ${mojo.javadoc("        ", $javadoc)}
        #if( $model.deprecated )
        @Deprecated
        #end
        default ${builderName} ${mojo.camelCaseLower($model.scheme)}(String path) {
            return ${builderName}Factory.endpointBuilder("${model.scheme}", path);
        }
        #set( $javadoc = $mojo.getMainDescription($model, true) + $newline + $newline
                            + "@param componentName to use a custom component name for the endpoint instead of the default name" + $newline
                            + "@param path " + $mojo.pathParameterJavaDoc($model) + $newline
                            + "@return the dsl builder" + $newline )
        ${mojo.javadoc("        ", $javadoc)}
        #if( $model.deprecated )
        @Deprecated
        #end
        default ${builderName} ${mojo.camelCaseLower($model.scheme)}(String componentName, String path) {
            return ${builderName}Factory.endpointBuilder(componentName, path);
        }
    #else
        #set( $firstAlias = true )
        #foreach( $componentModel in $aliases )
            #set( $javadoc = $mojo.getMainDescription($componentModel, true) + $newline + $newline
                            + "@param path " + $mojo.pathParameterJavaDoc($componentModel) + $newline
                            + "@return the dsl builder" + $newline )
        ${mojo.javadoc("        ", $javadoc)}
            #if( $componentModel.deprecated )
        @Deprecated
            #end
        default ${builderName} ${mojo.camelCaseLower($componentModel.scheme)}(String path) {
            return ${builderName}Factory.endpointBuilder("${componentModel.scheme}", path);
        }
            #if( $firstAlias )
                #set( $firstAlias = false )
                #set( $javadoc = $mojo.getMainDescription($componentModel, true) + $newline + $newline
                            + "@param componentName to use a custom component name for the endpoint instead of the default name" + $newline
                            + "@param path " + $mojo.pathParameterJavaDoc($componentModel) + $newline
                            + "@return the dsl builder" + $newline )
        ${mojo.javadoc("        ", $javadoc)}
                #if( $componentModel.deprecated )
        @Deprecated
                #end
        default ${builderName} ${mojo.camelCaseLower($componentModel.scheme)}(String componentName, String path) {
            return ${builderName}Factory.endpointBuilder(componentName, path);
        }
            #end
        #end
    #end

    }
    #if( !$model.endpointHeaders.empty )
    #set( $componentName = ${builderName.replace("EndpointBuilder", "")} )
    #set( $headerNameBuilder = ${componentName} + "HeaderNameBuilder" )
    /**
     * The builder of headers' name for the ${model.title} component.
     */
    public static class ${headerNameBuilder} {
        /**
         * The internal instance of the builder used to access to all the
         * methods representing the name of headers.
         */
        private static final ${headerNameBuilder} INSTANCE = new ${headerNameBuilder}();

        #foreach( $header in $model.endpointHeaders )
            #set( $headerName = $header.name )
            #if( $headerName.toLowerCase().startsWith("camel") )
                #set( $headerName = $headerName.substring(5) )
            #end
            #set( $name = $mojo.headerNameMethodName($headerName) )
            #set( $javadoc = $mojo.createBaseDescription($header, "header", true,
                    "${newline}The option is a: {@code " + $header.getJavaType() + "} type.") )
            #set( $javadoc = "$javadoc${newline}${newline}@return the name of the header {@code ${headerName}}." )
        ${mojo.javadoc("        ", $javadoc)}
            #if( $header.deprecated )
        @Deprecated
            #end
        public String ${name}() {
            return "${header.name}";
        }
        #end
    }
    #end
    static ${builderName} endpointBuilder(String componentName, String path) {
        class ${builderName}Impl extends AbstractEndpointBuilder implements ${builderName}#if($advanced), Advanced${builderName}#end {
            public ${builderName}Impl(String path) {
                super(componentName, path);
            }
        }
        return new ${builderName}Impl(path);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy