Class InjectUtil
java.lang.Object
eu.cloudnetservice.driver.inject.InjectUtil
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate static final BindingKey<?>[]private static final Object[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic @NonNull BindingKey<?>[]buildElementsForParameters(@NonNull Parameter[] parameters) Builds an element from the generic type and annotations of each given parameter.static @NonNull BindingKey<?>[]buildElementsForParameters(@NonNull Parameter[] parameters, int offset) Builds an element from the generic type and annotations of each given parameter.findAllInstances(@NonNull InjectionLayer<?> layer, @NonNull BindingKey<?>[] keys) Finds all instances that are requested by the given element array in the given injection layer.findAllInstances(@NonNull InjectionLayer<?> layer, @NonNull BindingKey<?>[] keys, int offset) Finds all instances that are requested by the given element array in the given injection layer.
-
Field Details
-
EMPTY_INSTANCE_ARRAY
-
EMPTY_ELEMENT_ARRAY
-
-
Constructor Details
-
InjectUtil
private InjectUtil()
-
-
Method Details
-
buildElementsForParameters
@NonNull public static @NonNull BindingKey<?>[] buildElementsForParameters(@NonNull @NonNull Parameter[] parameters) Builds an element from the generic type and annotations of each given parameter.- Parameters:
parameters- the parameters to build the element for.- Returns:
- an array of element each representing a given parameter, in order.
- Throws:
NullPointerException- if the given parameter array is null.
-
buildElementsForParameters
@NonNull public static @NonNull BindingKey<?>[] buildElementsForParameters(@NonNull @NonNull Parameter[] parameters, int offset) Builds an element from the generic type and annotations of each given parameter.- Parameters:
parameters- the parameters to build the element for.offset- the offset to begin construction from.- Returns:
- an array of element each representing a given parameter, in order.
- Throws:
NullPointerException- if the given parameter array is null.
-
findAllInstances
@NonNull public static @NonNull Object[] findAllInstances(@NonNull @NonNull InjectionLayer<?> layer, @NonNull @NonNull BindingKey<?>[] keys) Finds all instances that are requested by the given element array in the given injection layer.- Parameters:
layer- the layer to retrieve the needed instances from.keys- the keys to get the instances of.- Returns:
- the instances represented by the given elements, in order.
- Throws:
NullPointerException- if the given injection layer or elements array is null.
-
findAllInstances
@NonNull public static @NonNull Object[] findAllInstances(@NonNull @NonNull InjectionLayer<?> layer, @NonNull @NonNull BindingKey<?>[] keys, int offset) Finds all instances that are requested by the given element array in the given injection layer.- Parameters:
layer- the layer to retrieve the needed instances from.keys- the keys to get the instances of.offset- the offset to start writing the elements from in the resulting array, must be bigger than zero.- Returns:
- the instances represented by the given elements, in order.
- Throws:
NullPointerException- if the given injection layer or elements array is null.IllegalArgumentException- if the given offset is smaller than zero.
-