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