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.bean;
015
016/**
017 * An object describing the imminent destruction of a contextual instance by the {@link Factory#destroy(Object,
018 * Destruction)} method.
019 *
020 * <p>Any {@link Destruction} implementation <strong>must</strong> also be a {@link Creation} implementation, or
021 * undefined behavior and errors may occur.</p>
022 *
023 * @author <a href="https://about.me/lairdnelson" target="_top">Laird Nelson</a>
024 *
025 * @see #close()
026 *
027 * @see Creation
028 *
029 * @see ReferencesSelector
030 */
031public interface Destruction extends AutoCloseable, ReferencesSelector {
032
033  /**
034   * Closes this {@link Destruction} idempotently, normally thereby releasing a contextual instance's dependent objects
035   * that have been stored opaquely in this {@link Destruction} by some other mechanism at {@linkplain
036   * Factory#create(Creation) creation time}.
037   *
038   * <p>Many {@link Creation} implementations&mdash;and therefore {@link Destruction} implementations&mdash;are also
039   * {@link AutoCloseableRegistry} implementations, which is often how dependent objects are stored in the opaque manner
040   * mentioned above. This is not a requirement of either the {@link Creation} or {@link Destruction} contracts.</p>
041   *
042   * @see AutoCloseableRegistry
043   */
044  @Override // AutoCloseable
045  public default void close() {
046
047  }
048
049}