001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*-
002 *
003 * Copyright © 2023–2025 microBean™.
004 *
005 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
006 * the License. You may obtain a copy of the License at
007 *
008 *     http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
011 * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
012 * specific language governing permissions and limitations under the License.
013 */
014package org.microbean.reference;
015
016import java.util.function.Supplier;
017
018import org.microbean.bean.Request;
019
020/**
021 * A supplier of {@link ClientProxy} instances.
022 *
023 * @author <a href="https://about.me/lairdnelson" target="_top">Laird Nelson</a>
024 *
025 * @see #clientProxy(Request, Supplier)
026 */
027@FunctionalInterface
028public interface ClientProxier {
029
030  /**
031   * Returns a <dfn>contextual reference</dfn> which is also a {@link ClientProxy}, given a
032   * {@link Supplier} of <dfn>contextual instances</dfn> of the appropriate type.
033   *
034   * <p>Implementations of this method may return {@code null}.</p>
035   *
036   * @param <R> the type of the contextual reference
037   *
038   * @param r the {@link Request} necessitating this invocation; must not be {@code null}
039   *
040   * @param instanceSupplier a {@link Supplier} of contextual instances of the appropriate type; must not be {@code null}
041   *
042   * @return a contextual reference, which may be {@code null}
043   *
044   * @exception NullPointerException if any argument is {@code null}
045   *
046   * @see ClientProxy
047   */
048  public <R> R clientProxy(final Request<R> r, final Supplier<? extends R> instanceSupplier);
049
050}