001/* -*- mode: Java; c-basic-offset: 2; indent-tabs-mode: nil; coding: utf-8-unix -*- 002 * 003 * Copyright © 2023–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 016/** 017 * A representation of a {@link Factory}'s {@linkplain Factory#create(Request) creation activity}. 018 * 019 * @param <I> the type of instance being created 020 * 021 * @author <a href="https://about.me/lairdnelson" target="_parent">Laird Nelson</a> 022 */ 023@FunctionalInterface 024public interface Creation<I> { 025 026 /** 027 * Signals that the supplied {@code instance} has been created, typically by an invocation of a {@link Factory}'s 028 * {@link Factory#create(Request) create(Request)} method, and is about to be made available for use. 029 * 030 * <p>This method is typically invoked from within a {@link Factory#create(Request)} implementation immediately prior 031 * to its returning a value.</p> 032 * 033 * <p>It is permissible for an implementation of this method to do nothing.</p> 034 * 035 * @param instance the instance that was created; must not be {@code null} 036 * 037 * @exception NullPointerException if {@code instance} was {@code null} and the implementation does not support {@code 038 * null} arguments 039 * 040 * @exception IllegalArgumentException if {@code instance} was found to be unsuitable for any reason 041 * 042 * @idempotency Implementations of this method must be idempotent. 043 * 044 * @threadsafety Implementations of this method must be safe for concurrent use by multiple threads. 045 */ 046 // MUST be idempotent 047 // For incomplete instances; see also https://stackoverflow.com/questions/50202523/creationalcontext-should-a-custom-bean-always-call-push-from-its-create-met 048 public void created(final I instance); 049 050}