Interface InstanceResolver

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface InstanceResolver
Supplies instances for types the ServiceRegistry cannot create on its own.

Resolvers are asked before the registry creates a new instance. The first non-null result is stored in the registry as a singleton for the requested type.

 registry.addResolver(type -> type == Clock.class ? Clock.systemUTC() : null);
 
  • Method Summary

    Modifier and Type
    Method
    Description
    resolve(Class<?> type)
    Resolves an instance for the given type.
  • Method Details

    • resolve

      Object resolve(Class<?> type)
      Resolves an instance for the given type.
      Parameters:
      type - The requested type.
      Returns:
      An instance assignable to the type, or null if this resolver does not handle it.