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.producer;
015
016import java.util.Collection;
017
018import org.microbean.attributes.Attributes;
019
020import org.microbean.interceptor.InterceptorMethod;
021
022/**
023 * A collection of {@link InterceptorMethod}s indexed by {@link InterceptorMethodType}.
024 *
025 * @author <a href="https://about.me/lairdnelson" target="_top">Laird Nelson</a>
026 */
027public interface Interceptor extends AutoCloseable {
028
029  /**
030   * Closes this {@link Interceptor}, rendering it inappropriate for further use.
031   *
032   * <p>The default implementation of this method does nothing.</p>
033   */
034  @Override // AutoCloseable
035  public default void close() {
036
037  }
038
039  /**
040   * Returns a non-{@code null}, immutable, determinate {@link Collection} of {@link InterceptorMethod}s indexed under
041   * the supplied {@link InterceptorMethodType}.
042   *
043   * @param type an {@link InterceptorMethodType}; must not be {@code null}
044   *
045   * @return a non-{@code null}, immutable, determinate {@link Collection} of {@link InterceptorMethod}s indexed under
046   * the supplied {@link InterceptorMethodType}
047   *
048   * @exception NullPointerException if {@code type} is {@code null}
049   */
050  // "Give me the @AroundInvoke interceptor methods that are bound to the interceptor binding set that I am attributed
051  // with"
052  //
053  // Interceptor bindings must be at the class level and will therefore apply to all interceptor methods.
054  public Collection<? extends InterceptorMethod> interceptorMethods(final InterceptorMethodType type);
055
056}