001/*
002 * Copyright (C) 2007 The Guava Authors
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
005 * in compliance with the License. You may obtain a copy of the License at
006 *
007 * http://www.apache.org/licenses/LICENSE-2.0
008 *
009 * Unless required by applicable law or agreed to in writing, software distributed under the License
010 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
011 * or implied. See the License for the specific language governing permissions and limitations under
012 * the License.
013 */
014
015package com.google.common.base;
016
017import com.google.common.annotations.GwtCompatible;
018import com.google.errorprone.annotations.CanIgnoreReturnValue;
019
020/**
021 * Legacy version of {@code java.util.function.Supplier}. Semantically, this could be a factory,
022 * generator, builder, closure, or something else entirely. No guarantees are implied by this
023 * interface.
024 *
025 * <p>The {@link Suppliers} class provides common suppliers and related utilities.
026 *
027 * <p>As this interface extends {@link java.util.function.Supplier}, an instance of this type
028 * can be used as a {@code java.util.function.Supplier} directly.  To use a
029 * {@code java.util.function.Supplier} in a context where a
030 * {@code com.google.common.base.Supplier} is needed, use {@code supplier::get}.
031 *
032 * <p>See the Guava User Guide article on
033 * <a href="https://github.com/google/guava/wiki/FunctionalExplained">the use of {@code
034 * Function}</a>.
035 *
036 * @author Harry Heymann
037 * @since 2.0
038 */
039@GwtCompatible
040@FunctionalInterface
041public interface Supplier<T> extends java.util.function.Supplier<T> {
042  /**
043   * Retrieves an instance of the appropriate type. The returned object may or may not be a new
044   * instance, depending on the implementation.
045   *
046   * @return an instance of the appropriate type
047   */
048  @CanIgnoreReturnValue
049  T get();
050}