velocity.component-builder.vm Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of camel-package-maven-plugin Show documentation
Show all versions of camel-package-maven-plugin Show documentation
Maven plugin to help package Camel components and plugins
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="
")
/* 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 ${packageName};
import javax.annotation.processing.Generated;
import org.apache.camel.Component;
import ${dslPackage}.AbstractComponentBuilder;
import ${dslPackage}.ComponentBuilder;
import ${model.javaType};
#set( $lowerComponentName = $mojo.toCamelCaseLower($model.scheme) )
#set( $componentName = $mojo.capitalize($lowerComponentName) )
${mojo.javadoc("", $model.description + $newline + $newline + "Generated by camel build tools - do NOT edit this file!")}
@Generated("${generatorClass}")
public interface ${className} {
${mojo.javadoc(" ", $mojo.getMainDescriptionWithoutPathOptions($model) + $newline + $newline + "@return the dsl builder" + $newline)}
static ${componentName}ComponentBuilder ${lowerComponentName}() {
return new ${componentName}ComponentBuilderImpl();
}
/**
* Builder for the ${model.title} component.
*/
interface ${componentName}ComponentBuilder extends ComponentBuilder<${model.shortJavaType}> {
#foreach( $option in $model.componentOptions )
#set( $doc = $option.description )
#if( !$doc.endsWith(".") )
#set( $doc = $doc + "." )
#end
#if( $option.supportFileReference )
#set( $doc = $doc + $newline + $newline
+ "This option can also be loaded from an existing file, by prefixing with file: or "
+ "classpath: followed by the location of the file." )
#end
#set( $doc = $doc + $newline
+ $newline + "The option is a: " + $mojo.xmlEncode($option.javaType) + "
type." + $newline )
#if( $option.kind == "parameter" && $option.required )
#set( $doc = $doc + $newline + "Required: true" )
#end
#* include default value, if any *#
#if( $option.defaultValue || "$option.defaultValue" == "false" )
#* must xml encode description as in some rare cases it contains & chars which is invalid javadoc *#
#set( $doc = $doc + $newline + "Default: " + $mojo.xmlEncode($option.defaultValue) )
#end
#set( $doc = $doc + $newline + "Group: " + $option.group )
#set( $doc = $doc + $newline + $newline
+ "@param " + $option.name + " the value to set" + $newline
+ "@return the dsl builder" + $newline )
${mojo.javadoc(" ", $doc)}
#if( $option.deprecated )
@Deprecated
#end
default ${componentName}ComponentBuilder ${mojo.uncapitalize($option.name)}(${option.javaType} ${option.name}) {
doSetProperty("${option.name}", ${option.name});
return this;
}
#end
}
class ${componentName}ComponentBuilderImpl
extends AbstractComponentBuilder<${model.shortJavaType}>
implements ${componentName}ComponentBuilder {
@Override
protected ${model.shortJavaType} buildConcreteComponent() {
return new ${model.shortJavaType}();
}
#if( $configurationOption )
#set( $capField = $mojo.capitalize($configurationOption.configurationField) )
private ${configurationOption.configurationClass} getOrCreateConfiguration(${model.shortJavaType} component) {
if (component.get${capField}() == null) {
component.set${capField}(new ${configurationOption.configurationClass}());
}
return component.get${capField}();
}
#end
@Override
protected boolean setPropertyOnComponent(
Component component,
String name,
Object value) {
switch (name) {
#foreach( $option in $model.componentOptions )
#if( $option.configurationField )#set( $prefix = "getOrCreateConfiguration" )#else#set( $prefix = "" )#end
#set( $type = $option.javaType )
#if( $type.indexOf('<') != -1 )
#set( $type = $type.substring(0, $type.indexOf('<')) )
#end
#set( $type = $type.replace('$', '.') )
case "${option.name}": ${prefix}((${model.shortJavaType}) component).set${mojo.capitalize($option.name)}((${type}) value); return true;
#end
default: return false;
}
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy