ParameterResolverFactory

@InterfacedService(acceptMultiple = true)
abstract class ParameterResolverFactory<T : IParameterResolver<T>>(val resolverType: KClass<out T>)(source)

Factory for parameter resolvers.

Your implementation needs to be annotated with @ResolverFactory.

How it works

A factory determines if a given parameter is supported, if so, a parameter resolver will be created.

If multiple factories return true in isResolvable for a given type, the factory with the best priority is taken, if two with the same top priority exists, an exception is thrown.

Use cases

This is particularly useful if your parameter's type has generics, which you may read in ParameterWrapper.type, or if you need to read an annotation on the parameter to adjust the resolver's behavior, for example.

In case you want to read generics, you can read them off the KType in ParameterWrapper, but you can only do that with Kotlin.

In case you want to read the annotations, you can use the methods supplied by ParameterWrapper.

Parameters

T

Type of the returned parameter resolver

See also

Inheritors

Constructors

Link copied to clipboard
constructor(resolverType: Class<out T>)
constructor(resolverType: KClass<out T>)

Properties

Link copied to clipboard
open val priority: Int

The priority of this factory.

Link copied to clipboard
Link copied to clipboard

List of types as strings that are supported by this resolver factory.

Functions

Link copied to clipboard
abstract fun get(request: ResolverRequest): T

Returns a ParameterResolver for the given parameter.

Link copied to clipboard
abstract fun isResolvable(request: ResolverRequest): Boolean

Determines if a given parameter is supported, only one factory must return true.

Link copied to clipboard
open override fun toString(): String