Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/
package org.springframework.data.gemfire.util;
import static org.springframework.data.gemfire.util.ArrayUtils.nullSafeArray;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.Function;
import java.util.function.Supplier;
import org.springframework.beans.PropertyValue;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.config.BeanDefinition;
import org.springframework.beans.factory.config.RuntimeBeanReference;
import org.springframework.dao.InvalidDataAccessApiUsageException;
import org.springframework.util.StringUtils;
/**
* Abstract utility class encapsulating functionality common to {@link Object Objects}, {@link Class Class types}
* and Spring beans.
*
* @author John Blum
* @see java.lang.Class
* @see java.lang.Object
* @see org.springframework.beans.factory.BeanFactory
* @see org.springframework.beans.factory.config.BeanDefinition
* @see org.springframework.beans.factory.config.RuntimeBeanReference
* @since 1.8.0
*/
@SuppressWarnings("unused")
public abstract class SpringUtils {
/**
* Determines whether a given bean registered in the {@link BeanFactory Spring container} matches by
* both {@link String name} and {@link Class type}.
*
* @param beanFactory {@link BeanFactory Spring container} in which to resolve the bean.
* @param beanName {@link String name} of the bean.
* @param beanType {@link Class type} of the bean.
* @return a boolean value indicating whether the {@link BeanFactory Spring container} contains a bean
* matching by both {@link String name} as well as {@link Class type}.
* @see BeanFactory
* @see Class
* @see String
*/
public static boolean isMatchingBean(BeanFactory beanFactory, String beanName, Class beanType) {
return beanFactory.containsBean(beanName) && beanFactory.isTypeMatch(beanName, beanType);
}
public static BeanDefinition addDependsOn(BeanDefinition beanDefinition, String... beanNames) {
List dependsOnList = new ArrayList<>();
Collections.addAll(dependsOnList, nullSafeArray(beanDefinition.getDependsOn(), String.class));
dependsOnList.addAll(Arrays.asList(nullSafeArray(beanNames, String.class)));
beanDefinition.setDependsOn(dependsOnList.toArray(new String[0]));
return beanDefinition;
}
public static Optional