001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*- 002 * 003 * Copyright © 2024 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.bean; 015 016import java.util.Objects; 017 018/** 019 * An assignment of a contextual reference to an {@link AttributedElement}, usually as {@linkplain 020 * Request#reference(BeanSelectionCriteria) completed by} a {@link Request}. 021 * 022 * @param <R> the type of contextual reference 023 * 024 * @param assignee the {@link AttributedElement}; must not be {@code null} 025 * 026 * @param value the contextual reference; may be {@code null} 027 * 028 * @author <a href="https://about.me/lairdnelson" target="_top">Laird Nelson</a> 029 */ 030// You're going to be tempted to replace the value component with a Supplier component. Don't do it. An assignment is a 031// value that belongs to, e.g., a field, so even if the value "came from" none/dependent/prototype scope, it was already 032// sourced and "belongs to" the field. 033public record Assignment<R>(AttributedElement assignee, R value) { 034 035 /** 036 * Creates a new {@link Assignment}. 037 * 038 * @param assignee the {@link AttributedElement}; must not be {@code null} 039 * 040 * @param value the contextual reference; may be {@code null} 041 */ 042 public Assignment { 043 Objects.requireNonNull(assignee, "assignee"); 044 } 045 046}