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.Element[] EMPTY_ELEMENT_ARRAY
  • Constructor Details

    • InjectUtil

      private InjectUtil()
  • Method Details

    • buildElementsForParameters

      @NonNull public static @NonNull dev.derklaro.aerogel.Element[] 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.Element[] 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.Element[] elements)
      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.
      elements - the elements 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.
      dev.derklaro.aerogel.AerogelException - if an exception occurs while constructing a requested instance.
    • findAllInstances

      @NonNull public static @NonNull Object[] findAllInstances(@NonNull @NonNull InjectionLayer<?> layer, @NonNull @NonNull dev.derklaro.aerogel.Element[] elements, 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.
      elements - the elements 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.
      dev.derklaro.aerogel.AerogelException - if an exception occurs while constructing a requested instance.
    • createFixedBinding

      @NonNull public static @NonNull dev.derklaro.aerogel.binding.BindingConstructor createFixedBinding(@NonNull @NonNull Object value, @NonNull @NonNull Type... types)
      Creates a fixed binding constructor without setting any required name or annotation. It is only based on the type.
      Parameters:
      value - the value that is bound to the type.
      types - the types to bind the given value to.
      Returns:
      the new binding constructor.
      Throws:
      NullPointerException - if the given type or value is null.
      IndexOutOfBoundsException - if the given type array is empty.