Java 类org.apache.camel.spi.UriParam 实例源码

项目:Camel    文件:UriEndpointComponent.java   
protected static void populateParameterConfigurationMap(
        final SortedMap<String, ParameterConfiguration> parameterMap, Class<?> aClass,
        final String prefix) {
    ReflectionHelper.doWithFields(aClass, new ReflectionHelper.FieldCallback() {
        @Override
        public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException {
            UriParam uriParam = field.getAnnotation(UriParam.class);
            if (uriParam != null) {
                String name = uriParam.name();
                if (ObjectHelper.isEmpty(name)) {
                    name = field.getName();
                }
                String propertyName = prefix + name;

                // is the parameter a nested configuration object
                Class<?> fieldType = field.getType();
                UriParams uriParams = fieldType.getAnnotation(UriParams.class);
                if (uriParams != null) {
                    String nestedPrefix = uriParams.prefix();
                    if (nestedPrefix == null) {
                        nestedPrefix = "";
                    }
                    nestedPrefix = (prefix + nestedPrefix).trim();
                    populateParameterConfigurationMap(parameterMap, fieldType, nestedPrefix);
                } else {
                    if (parameterMap.containsKey(propertyName)) {
                        LOG.warn("Duplicate property name " + propertyName + " defined on field " + field);
                    } else {
                        parameterMap.put(propertyName,
                                ParameterConfiguration.newInstance(propertyName, field, uriParam));
                    }
                }
            }
        }
    });
}
项目:Camel    文件:ParameterConfiguration.java   
/**
 * Factory method to create a new ParameterConfiguration from a field
 */
public static ParameterConfiguration newInstance(String name, Field field, UriParam uriParam) {
    return new AnnotatedParameterConfiguration(name, field.getType(), field);
}