Class InjectUtil

java.lang.Object
eu.cloudnetservice.driver.inject.InjectUtil

@Internal public final class InjectUtil extends Object
Some general utility that comes handy for some internal tasks.
Since:
4.0
  • Field Details

    • EMPTY_INSTANCE_ARRAY

      private static final Object[] EMPTY_INSTANCE_ARRAY
    • EMPTY_ELEMENT_ARRAY

      private static final dev.derklaro.aerogel.binding.key.BindingKey<?>[] EMPTY_ELEMENT_ARRAY
  • Constructor Details

    • InjectUtil

      private InjectUtil()
  • Method Details

    • buildElementsForParameters

      @NonNull public static @NonNull dev.derklaro.aerogel.binding.key.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 dev.derklaro.aerogel.binding.key.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 dev.derklaro.aerogel.binding.key.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 dev.derklaro.aerogel.binding.key.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.