velocity.property-configurer.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.
## ---------------------------------------------------------------------------
/* Generated by camel build tools - do NOT edit this file! */
package ${package};
import javax.annotation.processing.Generated;
import java.util.Map;
import org.apache.camel.CamelContext;
import org.apache.camel.spi.ExtendedPropertyConfigurerGetter;
import org.apache.camel.spi.PropertyConfigurerGetter;
import org.apache.camel.spi.ConfigurerStrategy;
import org.apache.camel.spi.GeneratedPropertyConfigurer;
import org.apache.camel.util.CaseInsensitiveMap;
import ${pfqn};
/**
* Generated by camel build tools - do NOT edit this file!
*/
@Generated("${generatorClass}")
@SuppressWarnings("unchecked")
public class ${className} extends ${psn} implements GeneratedPropertyConfigurer, #if($extended)ExtendedPropertyConfigurerGetter#{else}PropertyConfigurerGetter#{end} {
#if ( $extended && ($model || ! $hasSuper) )
private static final Map ALL_OPTIONS;
static {
Map map = new CaseInsensitiveMap();
#if ( $model )
#if ( $component )
#foreach ( $option in $model.componentOptions )
#set( $ucOptionName = $option.name.substring(0, 1).toUpperCase() + $option.name.substring(1) )
map.put("${ucOptionName}", ${mojo.canonicalClassName($option.javaType)}.class);
#end
#else
#foreach ( $option in $model.endpointOptions )
#set( $ucOptionName = $option.name.substring(0, 1).toUpperCase() + $option.name.substring(1) )
map.put("${ucOptionName}", ${mojo.canonicalClassName($option.javaType)}.class);
#end
#end
#else
#foreach ( $option in $options )
#set( $ucOptionName = $option.name.substring(0, 1).toUpperCase() + $option.name.substring(1) )
map.put("${ucOptionName}", ${mojo.canonicalClassName($option.javaType)}.class);
#end
#end
ALL_OPTIONS = map;
#if ( $bootstrap )
ConfigurerStrategy.addBootstrapConfigurerClearer(${className}::clearBootstrapConfigurers);
#end
}
#end
#if ( $model && $model.name == "stub" && $options.empty && !$component )
@Override
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
super.configure(camelContext, obj, name, value, ignoreCase);
return true;
}
#elseif( !$options.empty || !$hasSuper )
#if ( $component )
#foreach ( $bo in $mojo.findConfigurations($options) )
#set ( $propName = $bo.configurationField.substring(0, 1).toUpperCase() + $bo.configurationField.substring(1) )
private ${bo.configurationClass} getOrCreate${propName}(${type} target) {
if (target.get${propName}() == null) {
target.set${propName}(new ${bo.configurationClass}());
}
return target.get${propName}();
}
#end
#end
@Override
public boolean configure(CamelContext camelContext, Object obj, String name, Object value, boolean ignoreCase) {
#if ( !$options.empty )
${type} target = (${type}) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
#foreach ( $option in $options )
#set ( $getOrSet = $option.name.substring(0, 1).toUpperCase() + $option.name.substring(1) )
#set ( $setterMethod = $option.setterMethod )
#set ( $configurationField = $option.configurationField )
#set ( $optionKind = $option.type )
#set ( $builder = $option.builderMethod )
#set ( $ptype = $mojo.canonicalClassName($option.javaType) )
#if ( $builder )
#set ( $prefix = "with" )
#else
#set ( $prefix = "set" )
#end
#if ( $configurationField )
#set ( $upConfigField = $configurationField.substring(0, 1).toUpperCase() + $configurationField.substring(1) )
#if ( $component )
#set ( $getOrSet = "getOrCreate${upConfigField}(target).${prefix}${getOrSet}" )
#else
#set ( $getOrSet = "target.get${upConfigField}().${prefix}${getOrSet}" )
#end
#else
#set ( $getOrSet = "target.${prefix}${getOrSet}" )
#end
#if ( $optionKind == "duration" && $ptype == "long" )
#set ( $rv = "property(camelContext, java.time.Duration.class, value).toMillis()" )
#else
#set ( $rv = "property(camelContext, ${ptype}.class, value)" )
#end
#if ( $setterMethod )
#set ( $rv = $mojo.format($setterMethod, $rv) )
#end
#if ( ! $option.name.toLowerCase().equals($option.name) )
case "${option.name.toLowerCase()}":
#end
case "${option.name}": ${getOrSet}(${rv}); return true;
#end
#if ( $stub )
default: return false;
#elseif ( $hasSuper )
default: return super.configure(camelContext, obj, name, value, ignoreCase);
#else
default: return false;
#end
}
#else
return false;
#end
}
#if ( $extended )
@Override
public Map getAllOptions(Object target) {
#if ( $model || !$hasSuper )
return ALL_OPTIONS;
#else
Map answer = super.getAllOptions(target);
#foreach ( $option in $options )
answer.put(${option.name}, ${mojo.canonicalClassName($option.type)});
#end
return answer;
#end
}
#end
#if ( $bootstrap && $extended )
public static void clearBootstrapConfigurers() {
ALL_OPTIONS.clear();
}
#end
#set ( $autowired = [] )
#foreach ( $option in $options )
#if ( $option.autowired )
#set ( $foo = $autowired.add($option) )
#end
#end
#if ( !$autowired.empty )
@Override
public String[] getAutowiredNames() {
return new String[]{#foreach($option in $autowired)"${option.name}"#if($foreach.hasNext), #end#end};
}
#end
@Override
public Class> getOptionType(String name, boolean ignoreCase) {
#if ( $options.empty )
return null;
#else
switch (ignoreCase ? name.toLowerCase() : name) {
#foreach ( $option in $options )
#set ( $lower = $option.name.toLowerCase() )
#if ( $lower != $option.name )
case "${lower}":
#end
case "${option.name}": return ${mojo.canonicalClassName($option.javaType)}.class;
#end
#if ( $hasSuper )
default: return super.getOptionType(name, ignoreCase);
#else
default: return null;
#end
}
#end
}
@Override
public Object getOptionValue(Object obj, String name, boolean ignoreCase) {
#if ( $options.empty )
return null;
#else
${type} target = (${type}) obj;
switch (ignoreCase ? name.toLowerCase() : name) {
#foreach ( $option in $options )
#set ( $getOrSet = $option.name.substring(0, 1).toUpperCase() + $option.name.substring(1) )
#set ( $ptype = $option.javaType )
#set ( $getterMethod = $option.getterMethod )
#set ( $configurationField = $option.configurationField )
#if ( !$getterMethod || $getterMethod.empty )
#if ( $ptype == "boolean" )
#set ( $prefix = "is" )
#else
#set ( $prefix = "get" )
#end
#else
#set ( $prefix = "" )
#set ( $getOrSet = $getterMethod )
#end
#if ( $configurationField )
#set ( $upConfigField = $configurationField.substring(0, 1).toUpperCase() + $configurationField.substring(1) )
#if ( $component )
#set ( $getOrSet = "getOrCreate${upConfigField}(target).${prefix}${getOrSet}()" )
#else
#set ( $getOrSet = "target.get${upConfigField}().${prefix}${getOrSet}()" )
#end
#else
#set ( $getOrSet = "target.${prefix}${getOrSet}()" )
#end
#set ( $lower = $option.name.toLowerCase() )
#if ( $lower != $option.name )
case "${lower}":
#end
case "${option.name}": return ${getOrSet};
#end
#if ( $hasSuper )
default: return super.getOptionValue(obj, name, ignoreCase);
#else
default: return null;
#end
}
#end
}
#set ( $nested = [] )
#foreach ( $option in $options )
#if ( $option.nestedType && !$option.nestedType.empty )
#set ( $foo = $nested.add($option) )
#end
#end
#if ( !$nested.empty )
@Override
public Object getCollectionValueType(Object target, String name, boolean ignoreCase) {
switch (ignoreCase ? name.toLowerCase() : name) {
#foreach ( $option in $nested )
#set ( $lower = $option.name.toLowerCase() )
#if ( $lower != $option.name )
case "${lower}":
#end
case "${option.name}": return ${mojo.canonicalClassName($option.nestedType)}.class;
#end
#if ( $hasSuper )
default: return super.getCollectionValueType(target, name, ignoreCase);
#else
default: return null;
#end
}
}
#end
#end
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy