Package org.apache.maven.di
Class Key<T>
java.lang.Object
org.apache.maven.di.Key<T>
- Type Parameters:
T- binding type
The key defines an identity of a binding. In any DI, a key is usually a type of the object along
with some optional tag to distinguish between bindings which make objects of the same type.
In ActiveJ Inject, a key is also a type token - special abstract class that can store type information with the shortest syntax possible in Java.
For example, to create a key of type Map<String, List<Integer>>, you can just use
this syntax: new Key<Map<String, List<Integer>>>(){}.
If your types are not known at compile time, you can use Types.parameterizedType(java.lang.reflect.Type, java.lang.reflect.Type, java.lang.reflect.Type[]) to make a
parameterized type and give it to a Key.ofType constructor.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns an underlying type with display string formatting (package names stripped) and prepended qualifier display string if this key has a qualifier.A shortcut for.Types.getRawType(Type)(key.getType())getType()<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> static <T> Key<T> static <T> Key<T> static <T> Key<T> toString()
-
Constructor Details
-
Key
protected Key() -
Key
-
Key
-
-
Method Details
-
of
-
of
-
ofType
-
ofType
-
getType
-
getRawType
A shortcut for. Also casts the result to a properly parameterized class.Types.getRawType(Type)(key.getType()) -
getTypeParameter
Returns 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
-
getDisplayString
Returns an underlying type with display string formatting (package names stripped) and prepended qualifier display string if this key has a qualifier. -
equals
-
hashCode
public int hashCode() -
toString
-