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

velocity.endpoint-uri-factory.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.
## ---------------------------------------------------------------------------
/* Generated by camel build tools - do NOT edit this file! */
package ${package};

import javax.annotation.processing.Generated;
import java.net.URISyntaxException;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;

import org.apache.camel.spi.EndpointUriFactory;

/**
 * Generated by camel build tools - do NOT edit this file!
 */
@Generated("${generatorClass}")
public class ${className} extends ${psn} implements EndpointUriFactory {

    private static final String BASE = "${model.syntax.replaceFirst($model.scheme, "")}";
#if ( $model.alternativeSchemes )
    #set ( $alt = $model.alternativeSchemes.split(",") )
    private static final String[] SCHEMES = new String[]{#foreach($s in $alt)"$s"#if($foreach.hasNext), #end#end};
#end

    private static final Set PROPERTY_NAMES;
    private static final Set SECRET_PROPERTY_NAMES;
    private static final Set MULTI_VALUE_PREFIXES;
    static {
#set( $props = $mojo.newTreeSet() )
#set( $secretProps = $mojo.newTreeSet() )
#set( $prefixes = $mojo.newTreeSet() )
#foreach( $opt in $model.endpointOptions )
    #set( $foo = $props.add( $opt.name ) )
    #if ( $opt.secret )
        #set( $foo = $secretProps.add( $opt.name ) )
    #end
    #if ( $opt.multiValue )
        #set( $foo = $prefixes.add( $opt.prefix ) )
    #end
#end
#foreach ( $a in $model.apiOptions )
    #foreach ( $m in $a.methods )
        #foreach ( $opt in $m.options )
            #set( $foo = $props.add( $opt.name ) )
            #if ( $opt.secret )
                #set( $foo = $secretProps.add( $opt.name ) )
            #end
            #if ( $opt.multiValue )
                #set( $foo = $prefixes.add( $opt.prefix ) )
            #end
        #end
    #end
#end
#if ( $props.empty )
        PROPERTY_NAMES = Collections.emptySet();
#else
        Set props = new HashSet<>(${props.size()});
    #foreach ( $prop in $props )
        props.add("${prop}");
    #end
        PROPERTY_NAMES = Collections.unmodifiableSet(props);
#end
#if ( $secretProps.empty )
        SECRET_PROPERTY_NAMES = Collections.emptySet();
#else
        Set secretProps = new HashSet<>(${secretProps.size()});
    #foreach ( $prop in $secretProps )
        secretProps.add("${prop}");
    #end
        SECRET_PROPERTY_NAMES = Collections.unmodifiableSet(secretProps);
#end
#if ( $prefixes.empty )
        MULTI_VALUE_PREFIXES = Collections.emptySet();
#else
        Set prefixes = new HashSet<>(${prefixes.size()});
    #foreach ( $prop in $prefixes )
        prefixes.add("${prop}");
    #end
        MULTI_VALUE_PREFIXES = Collections.unmodifiableSet(prefixes);
#end
    }

    @Override
    public boolean isEnabled(String scheme) {
    #if( $model.alternativeSchemes )
        for (String s : SCHEMES) {
            if (s.equals(scheme)) {
                return true;
            }
        }
        return false;
    #else
        return "${model.getScheme()}".equals(scheme);
    #end
    }

    @Override
    public String buildUri(String scheme, Map properties, boolean encode) throws URISyntaxException {
        String syntax = scheme + BASE;
        String uri = syntax;

        Map copy = new HashMap<>(properties);

    #foreach( $option in $model.endpointPathOptions )
        #if ( $option.defaultValue )
            #if ( $option.defaultValue.class.name == "java.lang.String" )
                #set ( $def = '"' + ${option.defaultValue} + '"' )
            #else
                #set ( $def = ${option.defaultValue} )
            #end
        #else
            #set ( $def = "null" )
        #end
        uri = buildPathParameter(syntax, uri, "${option.name}", ${def}, ${option.required}, copy);
    #end
        uri = buildQueryParameters(uri, copy, encode);
        return uri;
    }

    @Override
    public Set propertyNames() {
        return PROPERTY_NAMES;
    }

    @Override
    public Set secretPropertyNames() {
        return SECRET_PROPERTY_NAMES;
    }

    @Override
    public Set multiValuePrefixes() {
        return MULTI_VALUE_PREFIXES;
    }

    @Override
    public boolean isLenientProperties() {
        return ${model.lenientProperties};
    }
}





© 2015 - 2025 Weber Informatics LLC | Privacy Policy