Interface Lookup

All Superinterfaces:
Prototype.Api
All Known Implementing Classes:
Lookup.BuilderBase.LookupImpl

public interface Lookup extends Prototype.Api
Lookup criteria to discover services, mostly used when interacting with a service registry.
See Also:
  • Field Details

    • EMPTY

      static final Lookup EMPTY
      Empty lookup matches anything and everything except for abstract types.
  • Method Details

    • builder

      static Lookup.Builder builder()
      Create a new fluent API builder to customize configuration.
      Returns:
      a new builder
    • builder

      static Lookup.Builder builder(Lookup instance)
      Create a new fluent API builder from an existing instance.
      Parameters:
      instance - an existing instance used as a base for the builder
      Returns:
      a builder based on an instance
    • create

      static Lookup create(Dependency dependency)
      Create service lookup from this injection point information.
      Parameters:
      dependency - injection point to create lookup for
      Returns:
      lookup to match injection point
    • create

      static Lookup create(Class<?> contract)
      Create service lookup from a contract type.
      Parameters:
      contract - a single contract to base the lookup on
      Returns:
      lookup for matching services
    • create

      static Lookup create(TypeName contract)
      Create service lookup from a contract type.
      Parameters:
      contract - a single contract to base the lookup on
      Returns:
      lookup for matching services
    • serviceType

      Optional<TypeName> serviceType()
      The managed service implementation type name.
      Returns:
      the service type name
    • scopes

      Set<TypeName> scopes()
      The managed service assigned Scope. If empty, any scope is matched. If more than one value, any service in one of these scopes is matched.
      Returns:
      the service scope type name
    • qualifiers

      Set<Qualifier> qualifiers()
      The managed service assigned Qualifier's.
      Returns:
      the service qualifiers
    • contracts

      Set<ResolvedType> contracts()
      The managed services advertised types (i.e., typically its interfaces, can be through Service.ExternalContracts).
      Returns:
      the service contracts implemented
    • contractType

      Optional<GenericType<?>> contractType()
      A single GenericType can be defined if the lookup should also honor Service.QualifiedFactory services that can handle any type. This would be the target type to convert to. If not specified, Object will be used.
      Returns:
      generic type of the contract, if only one contract is desired
    • runLevel

      Optional<Double> runLevel()
      The optional Service.RunLevel ascribed to the service.
      Returns:
      the service's run level
    • weight

      Optional<Double> weight()
      Weight that was declared on the type itself.
      Returns:
      the declared weight
    • includeAbstract

      boolean includeAbstract()
      Whether to include abstract type service descriptors.
      Returns:
      whether to include abstract classes and interfaces
    • dependency

      Optional<Dependency> dependency()
      Optionally, the injection point search applies to. There are some service factories (such as Service.InjectionPointFactory) that provide instances for a specific injection point. Such factories may require an injection point to be present, and may fail otherwise.

      Injection points of each service are generated as public constants on their respective service descriptors.

      Returns:
      the optional injection point context info
    • factoryTypes

      Set<FactoryType> factoryTypes()
      If configured, the lookup will return service factories of the chosen types. If no factory types are defined, service instances are returned.

      Otherwise only service factories of the chosen types are returned, as follows:

      Returns:
      desired factory types
    • matches

      default boolean matches(Lookup criteria)
      Determines whether this lookup matches the criteria for injection. Matches is a looser form of equality check than equals(). If a service matches criteria it is generally assumed to be viable for assignability.
      Parameters:
      criteria - the criteria to compare against
      Returns:
      true if the criteria provided matches this instance
    • matches

      default boolean matches(ServiceInfo serviceInfo)
      Determines whether this service info criteria matches the service descriptor. Matches is a looser form of equality check than equals(). If a service matches criteria it is generally assumed to be viable for assignability.
      Parameters:
      serviceInfo - to compare with
      Returns:
      true if this criteria matches the service descriptor
    • matchesContracts

      default boolean matchesContracts(Lookup criteria)
      Determines whether the provided criteria match just the contracts portion of the provided criteria. Note that it is expected any external contracts have been consolidated into the regular contract section.
      Parameters:
      criteria - the criteria to compare against
      Returns:
      true if the criteria provided matches this instance from only the contracts point of view
    • matchesQualifiers

      default boolean matchesQualifiers(Set<Qualifier> qualifiers)
      Determines whether the provided qualifiers are matched by this lookup criteria.
      Parameters:
      qualifiers - qualifiers of a service
      Returns:
      whether this lookup matches those qualifiers