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 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
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 Details

    • CredentialsResolver

      protected CredentialsResolver(@NonNull Class<F> fromClass, @NonNull Class<T> toClass)
      Constructor.
      Parameters:
      fromClass - the class to resolve from.
      toClass - the class to resolve to.
    • CredentialsResolver

      protected CredentialsResolver(@NonNull Class<F> fromClass)
      Infers the to type of the corresponding 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.
      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 the CredentialsResolver for the specified type (if it exists)
      Type Parameters:
      C - the type.
      Parameters:
      clazz - the type.
      Returns:
      the CredentialsResolver to use or null if no resolver is required.
    • getFromClass

      @NonNull public Class<F> getFromClass()
      Returns the class to resolve from.
      Returns:
      the class to resolve from.
    • getToClass

      @NonNull public Class<T> getToClass()
      Returns the class to resolve to.
      Returns:
      the class to resolve to.
    • resolve

      @NonNull public T resolve(@NonNull F original)
      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

      @NonNull public final List<T> resolve(@CheckForNull Collection<? extends F> originals)
      Resolves the supplied credentials.
      Parameters:
      originals - credentials of the original type.
      Returns:
      the resolved credentials.
    • doResolve

      @NonNull protected abstract T doResolve(@NonNull F original)
      Resolves the supplied credentials.
      Parameters:
      original - the original type of credential.
      Returns:
      the resolved credentials.