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