Annotation Interface NameWith


@Documented @Retention(RUNTIME) @Target(TYPE) @Inherited public @interface NameWith
Often there is a requirement to get the names of different credentials in order to allow the user to select from multiple equivalent credentials. With Java 8 defender methods we could add a default method to Credentials however given the Java requirements of Jenkins we do not have this luxury. In any case different types of credentials will have different types of naming schemes, eg certificates vs username/password.

This annotation is applied to implementations or to marker interfaces. Where an implementation class is annotated, that annotation will always win, even if inherited. In the absence of the base class being annotated all the interfaces that the credential implements will be checked for the annotation. When checking multiple interfaces, the highest priority wins. The behaviour is indeterminate if there are multiple annotated interfaces with the same priority.

Since:
1.7
  • Required Element Summary

    Required Elements
    Modifier and Type
    Required Element
    Description
    The naming class to use.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    When forced to name via interfaces, the highest priority among all interfaces wins.
  • Element Details

    • priority

      int priority
      When forced to name via interfaces, the highest priority among all interfaces wins.
      Returns:
      the priority among interface based providers.
      Default:
      0