Java Code Examples for org.springframework.util.ObjectUtils#containsElement()

The following examples show how to use org.springframework.util.ObjectUtils#containsElement() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DirContextAdapter.java    From spring-ldap with Apache License 2.0 6 votes vote down vote up
private boolean isAttributeUpdated(Object[] values, boolean orderMatters, NameAwareAttribute orig) {
	int i = 0;
	for (Object obj : orig) {
		// TRUE if one value is not equal
		if (!(obj instanceof String)) {
			return true;
		}
		if (orderMatters) {
			// check only the string with same index
			if (!values[i].equals(obj)) {
				return true;
			}
		}
		else {
			// check all strings
			if (!ObjectUtils.containsElement(values, obj)) {
				return true;
			}
		}
		i++;
	}
	return false;
}
 
Example 2
Source File: BeanFactoryAnnotationUtils.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Check whether the named bean declares a qualifier of the given name.
 * @param qualifier the qualifier to match
 * @param beanName the name of the candidate bean
 * @param bf the {@code BeanFactory} from which to retrieve the named bean
 * @return {@code true} if either the bean definition (in the XML case)
 * or the bean's factory method (in the {@code @Bean} case) defines a matching
 * qualifier value (through {@code <qualifier>} or {@code @Qualifier})
 */
private static boolean isQualifierMatch(String qualifier, String beanName, ConfigurableListableBeanFactory bf) {
	if (bf.containsBean(beanName)) {
		try {
			BeanDefinition bd = bf.getMergedBeanDefinition(beanName);
			if (bd instanceof AbstractBeanDefinition) {
				AbstractBeanDefinition abd = (AbstractBeanDefinition) bd;
				AutowireCandidateQualifier candidate = abd.getQualifier(Qualifier.class.getName());
				if ((candidate != null && qualifier.equals(candidate.getAttribute(AutowireCandidateQualifier.VALUE_KEY))) ||
						qualifier.equals(beanName) || ObjectUtils.containsElement(bf.getAliases(beanName), qualifier)) {
					return true;
				}
			}
			if (bd instanceof RootBeanDefinition) {
				Method factoryMethod = ((RootBeanDefinition) bd).getResolvedFactoryMethod();
				if (factoryMethod != null) {
					Qualifier targetAnnotation = factoryMethod.getAnnotation(Qualifier.class);
					if (targetAnnotation != null && qualifier.equals(targetAnnotation.value())) {
						return true;
					}
				}
			}
		}
		catch (NoSuchBeanDefinitionException ex) {
			// Ignore - can't compare qualifiers for a manually registered singleton object
		}
	}
	return false;
}
 
Example 3
Source File: InitBinderDataBinderFactory.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Determine whether the given {@code @InitBinder} method should be used
 * to initialize the given {@link WebDataBinder} instance. By default we
 * check the specified attribute names in the annotation value, if any.
 */
protected boolean isBinderMethodApplicable(HandlerMethod initBinderMethod, WebDataBinder dataBinder) {
	InitBinder ann = initBinderMethod.getMethodAnnotation(InitBinder.class);
	Assert.state(ann != null, "No InitBinder annotation");
	String[] names = ann.value();
	return (ObjectUtils.isEmpty(names) || ObjectUtils.containsElement(names, dataBinder.getObjectName()));
}
 
Example 4
Source File: InitBinderDataBinderFactory.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Determine whether the given {@code @InitBinder} method should be used
 * to initialize the given {@link WebDataBinder} instance. By default we
 * check the specified attribute names in the annotation value, if any.
 */
protected boolean isBinderMethodApplicable(HandlerMethod initBinderMethod, WebDataBinder dataBinder) {
	InitBinder ann = initBinderMethod.getMethodAnnotation(InitBinder.class);
	Assert.state(ann != null, "No InitBinder annotation");
	String[] names = ann.value();
	return (ObjectUtils.isEmpty(names) || ObjectUtils.containsElement(names, dataBinder.getObjectName()));
}
 
Example 5
Source File: DefaultListableBeanFactory.java    From blog_demos with Apache License 2.0 4 votes vote down vote up
/**
 * Determine whether the given candidate name matches the bean name or the aliases
 * stored in this bean definition.
 */
protected boolean matchesBeanName(String beanName, String candidateName) {
	return (candidateName != null &&
			(candidateName.equals(beanName) || ObjectUtils.containsElement(getAliases(beanName), candidateName)));
}
 
Example 6
Source File: BeanDefinitionHolder.java    From blog_demos with Apache License 2.0 4 votes vote down vote up
/**
 * Determine whether the given candidate name matches the bean name
 * or the aliases stored in this bean definition.
 */
public boolean matchesName(String candidateName) {
	return (candidateName != null && (candidateName.equals(this.beanName) ||
			candidateName.equals(BeanFactoryUtils.transformedBeanName(this.beanName)) ||
			ObjectUtils.containsElement(this.aliases, candidateName)));
}
 
Example 7
Source File: BeanDefinitionHolder.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Determine whether the given candidate name matches the bean name
 * or the aliases stored in this bean definition.
 */
public boolean matchesName(String candidateName) {
	return (candidateName != null && (candidateName.equals(this.beanName) ||
			candidateName.equals(BeanFactoryUtils.transformedBeanName(this.beanName)) ||
			ObjectUtils.containsElement(this.aliases, candidateName)));
}
 
Example 8
Source File: DefaultListableBeanFactory.java    From spring-analysis-note with MIT License 4 votes vote down vote up
/**
 * Determine whether the given candidate name matches the bean name or the aliases
 * stored in this bean definition.
 */
protected boolean matchesBeanName(String beanName, @Nullable String candidateName) {
	return (candidateName != null &&
			(candidateName.equals(beanName) || ObjectUtils.containsElement(getAliases(beanName), candidateName)));
}
 
Example 9
Source File: BeanDefinitionHolder.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determine whether the given candidate name matches the bean name
 * or the aliases stored in this bean definition.
 */
public boolean matchesName(String candidateName) {
	return (candidateName != null && (candidateName.equals(this.beanName) ||
			candidateName.equals(BeanFactoryUtils.transformedBeanName(this.beanName)) ||
			ObjectUtils.containsElement(this.aliases, candidateName)));
}
 
Example 10
Source File: DefaultListableBeanFactory.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
/**
 * Determine whether the given candidate name matches the bean name or the aliases
 * stored in this bean definition.
 */
protected boolean matchesBeanName(String beanName, String candidateName) {
	return (candidateName != null &&
			(candidateName.equals(beanName) || ObjectUtils.containsElement(getAliases(beanName), candidateName)));
}
 
Example 11
Source File: DefaultListableBeanFactory.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
/**
 * Determine whether the given candidate name matches the bean name or the aliases
 * stored in this bean definition.
 */
protected boolean matchesBeanName(String beanName, String candidateName) {
	return (candidateName != null &&
			(candidateName.equals(beanName) || ObjectUtils.containsElement(getAliases(beanName), candidateName)));
}
 
Example 12
Source File: DefaultListableBeanFactory.java    From java-technology-stack with MIT License 4 votes vote down vote up
/**
 * Determine whether the given candidate name matches the bean name or the aliases
 * stored in this bean definition.
 */
protected boolean matchesBeanName(String beanName, @Nullable String candidateName) {
	return (candidateName != null &&
			(candidateName.equals(beanName) || ObjectUtils.containsElement(getAliases(beanName), candidateName)));
}
 
Example 13
Source File: EnumerablePropertySource.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Return whether this {@code PropertySource} contains a property with the given name.
 * <p>This implementation checks for the presence of the given name within the
 * {@link #getPropertyNames()} array.
 * @param name the name of the property to find
 */
@Override
public boolean containsProperty(String name) {
	return ObjectUtils.containsElement(getPropertyNames(), name);
}
 
Example 14
Source File: ProxyProcessorSupport.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Determine whether the given interface is just a container callback and
 * therefore not to be considered as a reasonable proxy interface.
 * <p>If no reasonable proxy interface is found for a given bean, it will get
 * proxied with its full target class, assuming that as the user's intention.
 * @param ifc the interface to check
 * @return whether the given interface is just a container callback
 */
protected boolean isConfigurationCallbackInterface(Class<?> ifc) {
	return (InitializingBean.class == ifc || DisposableBean.class == ifc || Closeable.class == ifc ||
			AutoCloseable.class == ifc || ObjectUtils.containsElement(ifc.getInterfaces(), Aware.class));
}
 
Example 15
Source File: ProxyProcessorSupport.java    From java-technology-stack with MIT License 2 votes vote down vote up
/**
 * Determine whether the given interface is just a container callback and
 * therefore not to be considered as a reasonable proxy interface.
 * <p>If no reasonable proxy interface is found for a given bean, it will get
 * proxied with its full target class, assuming that as the user's intention.
 * @param ifc the interface to check
 * @return whether the given interface is just a container callback
 */
protected boolean isConfigurationCallbackInterface(Class<?> ifc) {
	return (InitializingBean.class == ifc || DisposableBean.class == ifc || Closeable.class == ifc ||
			AutoCloseable.class == ifc || ObjectUtils.containsElement(ifc.getInterfaces(), Aware.class));
}
 
Example 16
Source File: EnumerablePropertySource.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Return whether this {@code PropertySource} contains a property with the given name.
 * <p>This implementation checks for the presence of the given name within the
 * {@link #getPropertyNames()} array.
 * @param name the name of the property to find
 */
@Override
public boolean containsProperty(String name) {
	return ObjectUtils.containsElement(getPropertyNames(), name);
}
 
Example 17
Source File: EnumerablePropertySource.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Return whether this {@code PropertySource} contains a property with the given name.
 * <p>This implementation checks for the presence of the given name within the
 * {@link #getPropertyNames()} array.
 * @param name the name of the property to find
 */
@Override
public boolean containsProperty(String name) {
	return ObjectUtils.containsElement(getPropertyNames(), name);
}
 
Example 18
Source File: MergedAnnotationPredicates.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a new {@link Predicate} that evaluates to {@code true} if the
 * {@linkplain MergedAnnotation#getType() merged annotation type} is contained in
 * the specified array.
 * @param <A> the annotation type
 * @param types the types that should be matched
 * @return a {@link Predicate} to test the annotation type
 */
public static <A extends Annotation> Predicate<MergedAnnotation<? extends A>> typeIn(Class<?>... types) {
	return annotation -> ObjectUtils.containsElement(types, annotation.getType());
}
 
Example 19
Source File: MergedAnnotationPredicates.java    From spring-analysis-note with MIT License 2 votes vote down vote up
/**
 * Create a new {@link Predicate} that evaluates to {@code true} if the
 * {@linkplain MergedAnnotation#getType() merged annotation type} is contained in
 * the specified array.
 * @param <A> the annotation type
 * @param typeNames the names that should be matched
 * @return a {@link Predicate} to test the annotation type
 */
public static <A extends Annotation> Predicate<MergedAnnotation<? extends A>> typeIn(String... typeNames) {
	return annotation -> ObjectUtils.containsElement(typeNames, annotation.getType().getName());
}
 
Example 20
Source File: ProxyProcessorSupport.java    From spring4-understanding with Apache License 2.0 2 votes vote down vote up
/**
 * Determine whether the given interface is just a container callback and
 * therefore not to be considered as a reasonable proxy interface.
 * <p>If no reasonable proxy interface is found for a given bean, it will get
 * proxied with its full target class, assuming that as the user's intention.
 * @param ifc the interface to check
 * @return whether the given interface is just a container callback
 */
protected boolean isConfigurationCallbackInterface(Class<?> ifc) {
	return (InitializingBean.class == ifc || DisposableBean.class == ifc ||
			ObjectUtils.containsElement(ifc.getInterfaces(), Aware.class));
}