001/* 002 * Copyright 2002-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.core.env; 018 019import java.util.stream.Stream; 020import java.util.stream.StreamSupport; 021 022import org.springframework.lang.Nullable; 023 024/** 025 * Holder containing one or more {@link PropertySource} objects. 026 * 027 * @author Chris Beams 028 * @author Juergen Hoeller 029 * @since 3.1 030 * @see PropertySource 031 */ 032public interface PropertySources extends Iterable<PropertySource<?>> { 033 034 /** 035 * Return a sequential {@link Stream} containing the property sources. 036 * @since 5.1 037 */ 038 default Stream<PropertySource<?>> stream() { 039 return StreamSupport.stream(spliterator(), false); 040 } 041 042 /** 043 * Return whether a property source with the given name is contained. 044 * @param name the {@linkplain PropertySource#getName() name of the property source} to find 045 */ 046 boolean contains(String name); 047 048 /** 049 * Return the property source with the given name, {@code null} if not found. 050 * @param name the {@linkplain PropertySource#getName() name of the property source} to find 051 */ 052 @Nullable 053 PropertySource<?> get(String name); 054 055}