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.Id; 019 020import org.microbean.proxy.Proxy; 021 022/** 023 * A source of {@link Proxy} instances representing <dfn>client proxies</dfn>. 024 * 025 * @author <a href="https://about.me/lairdnelson" target="_top">Laird Nelson</a> 026 * 027 * @see #clientProxy(Id, Supplier) 028 */ 029@FunctionalInterface 030public interface ClientProxier { 031 032 /** 033 * Returns a <dfn>contextual reference</dfn> which is also a {@link Proxy}, given a {@link Supplier} of 034 * <dfn>contextual instances</dfn> of the appropriate type. 035 * 036 * <p>Implementations of this method may return {@code null}.</p> 037 * 038 * @param <R> the type of the contextual reference 039 * 040 * @param id an {@link Id} qualifying the contextual instance that will be proxied; must not be {@code null} 041 * 042 * @param instanceSupplier a {@link Supplier} of contextual instances of the appropriate type; must not be {@code null} 043 * 044 * @return a contextual reference, which may be {@code null} 045 * 046 * @exception NullPointerException if any argument is {@code null} 047 * 048 * @see Proxy 049 */ 050 public <R> R clientProxy(final Id id, final Supplier<? extends R> instanceSupplier); 051 052}