Source:
static void configureFilter(BeanDefinitionBuilder synchronizerBuilder, Element element, ParserContext parserContext, Class<? extends FileListFilter<?>> patternClass, Class<? extends FileListFilter<?>> regexClass, Class<? extends AbstractPersistentAcceptOnceFileListFilter<?>> persistentAcceptOnceFileListFilterClass) { String filter = element.getAttribute("filter"); String filterExpression = element.getAttribute("filter-expression"); String fileNamePattern = element.getAttribute("filename-pattern"); String fileNameRegex = element.getAttribute("filename-regex"); boolean hasFilter = StringUtils.hasText(filter); boolean hasFilterExpression = StringUtils.hasText(filterExpression); boolean hasFileNamePattern = StringUtils.hasText(fileNamePattern); boolean hasFileNameRegex = StringUtils.hasText(fileNameRegex); if (hasFilter || hasFilterExpression || hasFileNamePattern || hasFileNameRegex) { int count = 0; if (hasFilter) { count++; } if (hasFileNamePattern) { count++; } if (hasFileNameRegex) { count++; } if (hasFilterExpression) { count++; } if (count != 1) { parserContext.getReaderContext().error("at most one of 'filename-pattern', " + "'filename-regex', 'filter' or 'filter-expression' is allowed on remote file inbound adapter", element); } if (hasFilter) { synchronizerBuilder.addPropertyReference("filter", filter); } else if (hasFilterExpression) { BeanDefinition expressionFilterBeanDefinition = BeanDefinitionBuilder.genericBeanDefinition(ExpressionFileListFilter.class) .addConstructorArgValue(filterExpression) .getBeanDefinition(); synchronizerBuilder.addPropertyValue("filter", expressionFilterBeanDefinition); } else if (hasFileNamePattern) { BeanDefinition patterFilter = BeanDefinitionBuilder.genericBeanDefinition(patternClass) .addConstructorArgValue(fileNamePattern) .getBeanDefinition(); composeFilters(synchronizerBuilder, persistentAcceptOnceFileListFilterClass, patterFilter); } else { BeanDefinition regexFilter = BeanDefinitionBuilder.genericBeanDefinition(regexClass) .addConstructorArgValue(fileNameRegex) .getBeanDefinition(); composeFilters(synchronizerBuilder, persistentAcceptOnceFileListFilterClass, regexFilter); } } }

Target:
static void configureFilter(BeanDefinitionBuilder synchronizerBuilder, Element element, ParserContext parserContext, Class<? extends FileListFilter<?>> patternClass, Class<? extends FileListFilter<?>> regexClass, Class<? extends AbstractPersistentAcceptOnceFileListFilter<?>> persistentAcceptOnceFileListFilterClass) { String filter = element.getAttribute("filter"); String filterExpression = element.getAttribute("filter-expression"); String fileNamePattern = element.getAttribute("filename-pattern"); String fileNameRegex = element.getAttribute("filename-regex"); boolean hasFilter = StringUtils.hasText(filter); boolean hasFilterExpression = StringUtils.hasText(filterExpression); boolean hasFileNamePattern = StringUtils.hasText(fileNamePattern); boolean hasFileNameRegex = StringUtils.hasText(fileNameRegex); if (hasFilter || hasFilterExpression || hasFileNamePattern || hasFileNameRegex) { int count = 0; if (hasFilter) { count++; } if (hasFileNamePattern) { count++; } if (hasFileNameRegex) { count++; } if (hasFilterExpression) { count++; } if (count != 1) { parserContext.getReaderContext().error("at most one of 'filename-pattern', " + "'filename-regex', 'filter' or 'filter-expression' is allowed on remote file inbound adapter", element); } if (hasFilter) { synchronizerBuilder.addPropertyReference("filter", filter); } else if (hasFilterExpression) { BeanDefinition expressionFilterBeanDefinition = BeanDefinitionBuilder.genericBeanDefinition(ExpressionFileListFilter.class) .addConstructorArgValue(filterExpression) .getBeanDefinition(); synchronizerBuilder.addPropertyValue("filter", expressionFilterBeanDefinition); } else if (hasFileNamePattern) { BeanDefinition patternFilter = BeanDefinitionBuilder.genericBeanDefinition(patternClass) .addConstructorArgValue(fileNamePattern) .getBeanDefinition(); composeFilters(synchronizerBuilder, persistentAcceptOnceFileListFilterClass, patternFilter); } else { BeanDefinition regexFilter = BeanDefinitionBuilder.genericBeanDefinition(regexClass) .addConstructorArgValue(fileNameRegex) .getBeanDefinition(); composeFilters(synchronizerBuilder, persistentAcceptOnceFileListFilterClass, regexFilter); } } }