Source:
<code>protected void configureFilter(BeanDefinitionBuilder builder, Element element, ParserContext parserContext, String filterAttribute, String patternPrefix, String propertyName) { String filter = element.getAttribute(filterAttribute); String filterExpression = element.getAttribute(filterAttribute + "-expression"); String fileNamePattern = element.getAttribute(patternPrefix + "-pattern"); String fileNameRegex = element.getAttribute(patternPrefix + "-regex"); boolean hasFilter = StringUtils.hasText(filter); boolean hasFilterExpression = StringUtils.hasText(filterExpression); boolean hasFileNamePattern = StringUtils.hasText(fileNamePattern); boolean hasFileNameRegex = StringUtils.hasText(fileNameRegex); int count = hasFilter ? 1 : 0; count += hasFilterExpression ? 1 : 0; count += hasFileNamePattern ? 1 : 0; count += hasFileNameRegex ? 1 : 0; <START> if (count > 1) { <END> parserContext.getReaderContext().error("at most one of '" + patternPrefix + "-pattern', " + "'" + patternPrefix + "-regex', or '" + filterAttribute + "' is allowed on a remote file outbound gateway", element); } else if (hasFilter) { builder.addPropertyReference(propertyName, filter); } else if (hasFilterExpression) { BeanDefinition expressionFilterBeanDefinition = BeanDefinitionBuilder.genericBeanDefinition(ExpressionFileListFilter.class) .addConstructorArgValue(filterExpression) .getBeanDefinition(); builder.addPropertyValue(propertyName, expressionFilterBeanDefinition); } else if (hasFileNamePattern) { BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.genericBeanDefinition( "filter".equals(filterAttribute) ? this.getSimplePatternFileListFilterClassName() : SimplePatternFileListFilter.class.getName()); filterBuilder.addConstructorArgValue(fileNamePattern); builder.addPropertyValue(propertyName, filterBuilder.getBeanDefinition()); } else if (hasFileNameRegex) { BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.genericBeanDefinition( "filter".equals(filterAttribute) ? this.getRegexPatternFileListFilterClassName() : RegexPatternFileListFilter.class.getName()); filterBuilder.addConstructorArgValue(fileNameRegex); builder.addPropertyValue(propertyName, filterBuilder.getBeanDefinition()); } }</code><technical_language>Need enhance error message</technical_language>

Target:
protected void configureFilter(BeanDefinitionBuilder builder, Element element, ParserContext parserContext, String filterAttribute, String patternPrefix, String propertyName) { String filter = element.getAttribute(filterAttribute); String filterExpression = element.getAttribute(filterAttribute + "-expression"); String fileNamePattern = element.getAttribute(patternPrefix + "-pattern"); String fileNameRegex = element.getAttribute(patternPrefix + "-regex"); boolean hasFilter = StringUtils.hasText(filter); boolean hasFilterExpression = StringUtils.hasText(filterExpression); boolean hasFileNamePattern = StringUtils.hasText(fileNamePattern); boolean hasFileNameRegex = StringUtils.hasText(fileNameRegex); int count = hasFilter ? 1 : 0; count += hasFilterExpression ? 1 : 0; count += hasFileNamePattern ? 1 : 0; count += hasFileNameRegex ? 1 : 0; if (count > 1) { parserContext.getReaderContext() .error("at most one of '" + patternPrefix + "-pattern', " + "'" + patternPrefix + "-regex', '" + filterAttribute + "' or '" + filterAttribute + "-expression' is allowed on a remote file outbound gateway", element); } else if (hasFilter) { builder.addPropertyReference(propertyName, filter); } else if (hasFilterExpression) { BeanDefinition expressionFilterBeanDefinition = BeanDefinitionBuilder.genericBeanDefinition(ExpressionFileListFilter.class) .addConstructorArgValue(filterExpression) .getBeanDefinition(); builder.addPropertyValue(propertyName, expressionFilterBeanDefinition); } else if (hasFileNamePattern) { BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.genericBeanDefinition( "filter".equals(filterAttribute) ? this.getSimplePatternFileListFilterClassName() : SimplePatternFileListFilter.class.getName()); filterBuilder.addConstructorArgValue(fileNamePattern); builder.addPropertyValue(propertyName, filterBuilder.getBeanDefinition()); } else if (hasFileNameRegex) { BeanDefinitionBuilder filterBuilder = BeanDefinitionBuilder.genericBeanDefinition( "filter".equals(filterAttribute) ? this.getRegexPatternFileListFilterClassName() : RegexPatternFileListFilter.class.getName()); filterBuilder.addConstructorArgValue(fileNameRegex); builder.addPropertyValue(propertyName, filterBuilder.getBeanDefinition()); } }