001package io.avaje.inject;
002
003import io.avaje.lang.NonNullApi;
004
005import java.util.Set;
006
007/**
008 * A bean entry with priority and optional name.
009 *
010 * @see BeanScope#all()
011 */
012@NonNullApi
013public interface BeanEntry {
014
015  /**
016   * Priority of externally supplied bean.
017   */
018  int SUPPLIED = 2;
019
020  /**
021   * Priority of <code>@Primary</code> bean.
022   */
023  int PRIMARY = 1;
024
025  /**
026   * Priority of normal bean.
027   */
028  int NORMAL = 0;
029
030  /**
031   * Priority of <code>@Secondary</code> bean.
032   */
033  int SECONDARY = -1;
034
035  /**
036   * Return the bean name.
037   */
038  String qualifierName();
039
040  /**
041   * Return the bean instance.
042   */
043  Object bean();
044
045  /**
046   * The bean instance type.
047   */
048  Class<?> type();
049
050  /**
051   * Return the priority indicating if the bean is Supplied Primary, Normal or Secondary.
052   */
053  int priority();
054
055  /**
056   * Return the type keys for this bean.
057   * <p>
058   * This is the set of type, interface types and annotation types that the entry is registered for.
059   */
060  Set<String> keys();
061
062  /**
063   * Return true if the entry has a key for this type.
064   * <p>
065   * This is true if the keys contains the canonical name of the given type.
066   *
067   * @param type The type to match. Can be any type including concrete, interface or annotation type.
068   */
069  boolean hasKey(Class<?> type);
070
071}