org.apache.cayenne.di

## Class Key<T>

- java.lang.Object
- - org.apache.cayenne.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 binding name.
  Since:
    3.1

- - ### Field Summary

    Fields
    Modifier and Type | Field and Description
    --- | ---
    `protected String` | `bindingName`
    `protected org.apache.cayenne.di.TypeLiteral<T>` | `typeLiteral`

  - ### Constructor Summary

    Constructors
    Modifier | Constructor and Description
    --- | ---
    `protected` | `Key(org.apache.cayenne.di.TypeLiteral<T> type, String bindingName)`

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `boolean` | `equals(Object object)`
    `static <T> Key<T>` | `get(Class<T> type)` Creates a key for a nameless binding of a given type.
    `static <T> Key<T>` | `get(Class<T> type, String bindingName)` Creates a key for a named binding of a given type.
    `String` | `getBindingName()` Returns an optional name of the binding used to distinguish multiple bindings of the same object type.
    `static <T> Key<List<T>>` | `getListOf(Class<T> type)`
    `static <T> Key<List<T>>` | `getListOf(Class<T> type, String bindingName)`
    `static <K,V> Key<Map<K,V>>` | `getMapOf(Class<K> keyType, Class<V> valueType)`
    `static <K,V> Key<Map<K,V>>` | `getMapOf(Class<K> keyType, Class<V> valueType, String bindingName)`
    `Class<T>` | `getType()`
    `int` | `hashCode()`
    `String` | `toString()`

    - ### Methods inherited from class java.lang.Object

      `clone, finalize, getClass, notify, notifyAll, wait, wait, wait`

- - ### Field Detail

    - #### typeLiteral

          protected org.apache.cayenne.di.TypeLiteral<T> typeLiteral

      Since:
        4.0

    - #### bindingName

          protected String bindingName

  - ### Constructor Detail

    - #### Key

          protected Key(org.apache.cayenne.di.TypeLiteral<T> type,
                        String bindingName)

  - ### Method Detail

    - #### 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.

    - #### getListOf

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

      Since:
        4.0

    - #### getListOf

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

      Since:
        4.0

    - #### getMapOf

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

      Since:
        4.0

    - #### getMapOf

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

      Since:
        4.0

    - #### getType

          public Class<T> getType()

    - #### getBindingName

          public String getBindingName()

      Returns an optional name of the binding used to distinguish multiple bindings of the same object type.

    - #### 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`

Copyright © 2001–2021 Apache Cayenne. All rights reserved.