Class Key<T>

java.lang.Object
io.bootique.di.Key<T>

public class Key<T> extends Object
An object that encapsulates a key used to store and lookup DI bindings. Key is made of a binding type and an optional qualifier (name or annotation).
  • Constructor Details

  • Method Details

    • get

      public static <T> Key<T> get(Class<T> type)
      Creates a key for a nameless binding of a given type.
    • get

      public static <T> Key<T> get(Class<T> type, String bindingName)
      Creates a key for a named binding of a given type. 'bindingName' that is an empty String is treated the same way as a null 'bindingName'. In both cases a nameless binding key is created.
    • get

      public static <T> Key<T> get(Class<T> type, Class<? extends Annotation> annotationType)
      Creates a key for a qualified by annotation binding of a given type.
    • get

      public static <T> Key<T> get(Class<T> type, Annotation annotationInstance)
    • get

      public static <T> Key<T> get(TypeLiteral<T> typeLiteral)
    • get

      public static <T> Key<T> get(TypeLiteral<T> typeLiteral, String bindingName)
    • get

      public static <T> Key<T> get(TypeLiteral<T> typeLiteral, Class<? extends Annotation> annotationType)
    • get

      public static <T> Key<T> get(TypeLiteral<T> typeLiteral, Annotation annotationInstance)
    • getListOf

      public static <T> Key<List<T>> getListOf(Class<T> type, Class<? extends Annotation> qualifier)
    • getListOf

      public static <T> Key<List<T>> getListOf(Class<T> type, String bindingName)
    • getListOf

      public static <T> Key<List<T>> getListOf(Class<T> type)
    • getSetOf

      public static <T> Key<Set<T>> getSetOf(Class<T> valueType, Class<? extends Annotation> qualifier)
    • getSetOf

      public static <T> Key<Set<T>> getSetOf(Class<T> valueType, String bindingName)
    • getSetOf

      public static <T> Key<Set<T>> getSetOf(Class<T> valueType)
    • getMapOf

      public static <K, V> Key<Map<K,V>> getMapOf(Class<K> keyType, Class<V> valueType, Class<? extends Annotation> qualifier)
    • getMapOf

      public static <K, V> Key<Map<K,V>> getMapOf(Class<K> keyType, Class<V> valueType, String bindingName)
    • getMapOf

      public static <K, V> Key<Map<K,V>> getMapOf(Class<K> keyType, Class<V> valueType)
    • getMapOf

      public static <K, V> Key<Map<K,V>> getMapOf(TypeLiteral<K> keyType, TypeLiteral<V> valueType, Class<? extends Annotation> qualifier)
    • getMapOf

      public static <K, V> Key<Map<K,V>> getMapOf(TypeLiteral<K> keyType, TypeLiteral<V> valueType, String bindingName)
    • getMapOf

      public static <K, V> Key<Map<K,V>> getMapOf(TypeLiteral<K> keyType, TypeLiteral<V> valueType)
    • getOptionalOf

      public static <T> Key<Optional<T>> getOptionalOf(Class<? extends T> type)
    • getOptionalOf

      public static <T> Key<Optional<T>> getOptionalOf(Key<T> key)
      Creates Optional<T> version of given key
    • getType

      public TypeLiteral<T> getType()
    • getBindingName

      public String getBindingName()
      Returns an optional name of the binding used to distinguish multiple bindings of the same object type.
    • getBindingAnnotation

      public Class<? extends Annotation> getBindingAnnotation()
    • equals

      public boolean equals(Object object)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • toString

      public String toString()
      Overrides:
      toString in class Object