Class CredentialsResolver<F extends Credentials,T extends Credentials>
java.lang.Object
com.cloudbees.plugins.credentials.CredentialsResolver<F,T>
- Type Parameters:
F
- the class that the resolver resolves from.T
- the class that the resolver resolves to. Typically this class will have areadResolve()
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
Translates
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.- Since:
- 1.6
- See Also:
-
Constructor Summary
ModifierConstructorDescriptionprotected
CredentialsResolver
(Class<F> fromClass) Infers the to type of the correspondingCredentials
from the outer class.protected
CredentialsResolver
(Class<F> fromClass, Class<T> toClass) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract T
Resolves the supplied credentials.Returns the class to resolve from.static <C extends Credentials>
CredentialsResolver<Credentials,C> getResolver
(Class<C> clazz) Retrieves theCredentialsResolver
for the specified type (if it exists)Returns the class to resolve to.Resolves the supplied credentials.resolve
(Collection<? extends F> originals) Resolves the supplied credentials.
-
Constructor Details
-
CredentialsResolver
Constructor.- Parameters:
fromClass
- the class to resolve from.toClass
- the class to resolve to.
-
CredentialsResolver
Infers the to type of the correspondingCredentials
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.- Parameters:
fromClass
- the class to resolve from.
-
-
Method Details
-
getResolver
@CheckForNull public static <C extends Credentials> CredentialsResolver<Credentials,C> getResolver(@NonNull Class<C> clazz) Retrieves theCredentialsResolver
for the specified type (if it exists)- Type Parameters:
C
- the type.- Parameters:
clazz
- the type.- Returns:
- the
CredentialsResolver
to use ornull
if no resolver is required.
-
getFromClass
Returns the class to resolve from.- Returns:
- the class to resolve from.
-
getToClass
Returns the class to resolve to.- Returns:
- the class to resolve to.
-
resolve
Resolves the supplied credentials.- Parameters:
original
- the original type of credential.- Returns:
- the resolved credentials or the original if they already implement the required interface.
-
resolve
Resolves the supplied credentials.- Parameters:
originals
- credentials of the original type.- Returns:
- the resolved credentials.
-
doResolve
Resolves the supplied credentials.- Parameters:
original
- the original type of credential.- Returns:
- the resolved credentials.
-