Example usage for org.springframework.util CollectionUtils findFirstMatch

List of usage examples for org.springframework.util CollectionUtils findFirstMatch

Introduction

In this page you can find the example usage for org.springframework.util CollectionUtils findFirstMatch.

Prototype

@SuppressWarnings("unchecked")
@Nullable
public static <E> E findFirstMatch(Collection<?> source, Collection<E> candidates) 

Source Link

Document

Return the first element in ' candidates ' that is contained in ' source '.

Usage

From source file:org.eclipse.gemini.blueprint.blueprint.config.internal.BlueprintParser.java

/**
 * Validate that the specified bean name and aliases have not been used already.
 *//*from  w w w .j ava  2  s  .  c o  m*/
private boolean checkNameUniqueness(String beanName, Collection<String> aliases, Collection<String> usedNames) {
    String foundName = null;

    if (StringUtils.hasText(beanName) && usedNames.contains(beanName)) {
        foundName = beanName;
    }
    if (foundName == null) {
        foundName = (String) CollectionUtils.findFirstMatch(usedNames, aliases);
    }

    usedNames.add(beanName);
    usedNames.addAll(aliases);

    return (foundName != null);
}

From source file:org.springframework.beans.factory.xml.BeanDefinitionParserDelegate.java

/**
 * Validate that the specified bean name and aliases have not been used already
 * within the current level of beans element nesting.
 *//*from  w  w w  .j  a  v  a  2 s  .  co  m*/
protected void checkNameUniqueness(String beanName, List<String> aliases, Element beanElement) {
    String foundName = null;

    if (StringUtils.hasText(beanName) && this.usedNames.contains(beanName)) {
        foundName = beanName;
    }
    if (foundName == null) {
        foundName = CollectionUtils.findFirstMatch(this.usedNames, aliases);
    }
    if (foundName != null) {
        error("Bean name '" + foundName + "' is already used in this <beans> element", beanElement);
    }

    this.usedNames.add(beanName);
    this.usedNames.addAll(aliases);
}