Class Key<T>
java.lang.Object
org.apache.maven.di.Key<T>
- Type Parameters:
- T- The type this key represents
A binding key that uniquely identifies a dependency in the injection system.
 
Keys combine a type with an optional qualifier to uniquely identify dependencies within the injection system. They also serve as type tokens, allowing preservation of generic type information at runtime.
Example usage:
 // Simple key for a type
 Key<Service> simple = Key.of(Service.class);
 // Key with generic type information
 Key<List<String>> generic = new Key<List<String>>(){};
 // Key with qualifier
 Key<Service> qualified = Key.of(Service.class, "primary");
 - Since:
- 4.0.0
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionbooleanReturns an underlying type with display string formatting (package names stripped) and prepended qualifier display string if this key has a qualifier.Returns the qualifier associated with this key, if any.A shortcut forTypes.getRawType(Type)(key.getType())getType()Returns the actual type represented by this key.<U> Key<U> getTypeParameter(int index) Returns a type parameter of the underlying type wrapped as a key with no qualifier.inthashCode()static <T> Key<T> Creates a new Key instance for the specified type.static <T> Key<T> Creates a new Key instance for the specified type with a qualifier.static <T> Key<T> static <T> Key<T> toString()
- 
Constructor Details- 
Keyprotected Key()
- 
Key
- 
Key
 
- 
- 
Method Details- 
ofCreates a new Key instance for the specified type.- Type Parameters:
- T- the type parameter
- Parameters:
- type- the Class object representing the type
- Returns:
- a new Key instance
- Throws:
- NullPointerException- if type is null
 
- 
ofCreates a new Key instance for the specified type with a qualifier.- Type Parameters:
- T- the type parameter
- Parameters:
- type- the Class object representing the type
- qualifier- the qualifier object (typically an annotation instance)
- Returns:
- a new Key instance
- Throws:
- NullPointerException- if type is null
 
- 
ofType
- 
ofType
- 
getTypeReturns the actual type represented by this key.This includes full generic type information if available. - Returns:
- the type represented by this key
 
- 
getRawTypeA shortcut forTypes.getRawType(Type)(key.getType())
- 
getTypeParameterReturns a type parameter of the underlying type wrapped as a key with no qualifier.- Throws:
- IllegalStateException- when underlying type is not a parameterized one.
 
- 
getQualifier
- 
getDisplayStringReturns an underlying type with display string formatting (package names stripped) and prepended qualifier display string if this key has a qualifier.
- 
equals
- 
hashCode
- 
toString
 
-