F
- the class that the resolver resolves from.T
- the class that the resolver resolves to. Typically this class will have a readResolve()
method
that returns an instance of the class that the resolver resolves from.public abstract class CredentialsResolver<F extends Credentials,T extends Credentials> extends Object
Credentials
from one type into another. We only support point-to-point translation, not a chain.
Translation is designed to help plugins migrate towards common credential interfaces once they have been
standardized, so the intention is that a plugin that implemented an old credential type and has migrated to the
new type would also provide a translator.ResolveWith
Modifier | Constructor and Description |
---|---|
protected |
CredentialsResolver(Class<F> fromClass)
Infers the to type of the corresponding
Credentials from the outer class. |
protected |
CredentialsResolver(Class<F> fromClass,
Class<T> toClass)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
protected abstract T |
doResolve(F original)
Resolves the supplied credentials.
|
Class<F> |
getFromClass()
Returns the class to resolve from.
|
static <C extends Credentials> |
getResolver(Class<C> clazz)
Retrieves the
CredentialsResolver for the specified type (if it exists) |
Class<T> |
getToClass()
Returns the class to resolve to.
|
List<T> |
resolve(Collection<? extends F> originals)
Resolves the supplied credentials.
|
T |
resolve(F original)
Resolves the supplied credentials.
|
protected CredentialsResolver(@NonNull Class<F> fromClass, @NonNull Class<T> toClass)
fromClass
- the class to resolve from.toClass
- the class to resolve to.protected CredentialsResolver(@NonNull Class<F> fromClass)
Credentials
from the outer class.
This version works when you follow the common convention, where a resolver
is written as the static nested class of the resolved class.fromClass
- the class to resolve from.@NonNull public Class<F> getFromClass()
@NonNull public Class<T> getToClass()
@NonNull public T resolve(@NonNull F original)
original
- the original type of credential.@NonNull public final List<T> resolve(@CheckForNull Collection<? extends F> originals)
originals
- credentials of the original type.@NonNull protected abstract T doResolve(@NonNull F original)
original
- the original type of credential.@CheckForNull public static <C extends Credentials> CredentialsResolver<Credentials,C> getResolver(@NonNull Class<C> clazz)
CredentialsResolver
for the specified type (if it exists)C
- the type.clazz
- the type.CredentialsResolver
to use or null
if no resolver is required.Copyright © 2016. All rights reserved.