Class TargetConstructorCache<T>

java.lang.Object
io.micronaut.core.beans.TargetConstructorCache<T>
Type Parameters:
T - The bean type

@Internal public final class TargetConstructorCache<T> extends Object
Holds the Constructor a BeanConstructor resolved, so that it is resolved once, whether or not there is one. A null result is held the same way as a found constructor: the bean type may not declare a constructor with the arguments, or the bean may not be created through a constructor at all.
Since:
5.2.2
Author:
Denis Stepanov
  • Constructor Details

    • TargetConstructorCache

      public TargetConstructorCache()
  • Method Details

    • get

      public @Nullable Constructor<T> get(Supplier<@Nullable Constructor<T>> resolver)
      Returns the held constructor, resolving it on the first call. Concurrent first calls may each resolve, and hold equal constructors.
      Parameters:
      resolver - The resolution
      Returns:
      The constructor, or null if the resolution produced none
    • resolve

      public static <T> @Nullable Constructor<T> resolve(BeanConstructor<T> beanConstructor)
      Resolves the declared constructor of the bean type whose parameter types are the raw types of the bean constructor's arguments, the resolution BeanConstructor.getTargetConstructor() performs by default.
      Type Parameters:
      T - The bean type
      Parameters:
      beanConstructor - The bean constructor
      Returns:
      The constructor, or null if the bean type declares no such constructor