org.springframework.boot.context.annotation.Configurations Maven / Gradle / Ivy
/*
* Copyright 2012-2018 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.boot.context.annotation;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.springframework.context.ApplicationContext;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.ImportSelector;
import org.springframework.core.OrderComparator;
import org.springframework.core.Ordered;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
/**
* A set of {@link Configuration @Configuration} classes that can be registered in
* {@link ApplicationContext}. Classes can be returned from one or more
* {@link Configurations} instances by using {@link #getClasses(Configurations[])}. The
* resulting array follows the ordering rules usually applied by the
* {@link ApplicationContext} and/or custom {@link ImportSelector} implementations.
*
* This class is primarily intended for use with tests that need to specify configuration
* classes but can't use {@link SpringRunner}.
*
* Implementations of this class should be annotated with {@code @Order} or implement
* {@link Ordered}.
*
* @author Phillip Webb
* @since 2.0.0
* @see UserConfigurations
*/
public abstract class Configurations {
private static final Comparator