Class AvatarMetadataAction

java.lang.Object
hudson.model.InvisibleAction
jenkins.scm.api.metadata.AvatarMetadataAction
All Implemented Interfaces:
Action, ModelObject, Serializable

@ExportedBean public abstract class AvatarMetadataAction extends InvisibleAction implements Serializable
Holds metadata about an avatar to be associated with a SCMSource or SCMNavigator (also valid for SCMRevision and SCMHead, but would be considered unusual).

For example:

Since:
2.0
See Also:
  • Constructor Details

    • AvatarMetadataAction

      public AvatarMetadataAction()
  • Method Details

    • getAvatarIconClassName

      @CheckForNull public String getAvatarIconClassName()
      Returns the Icon class specification for the avatar of this object
      Returns:
      the Icon class specification or null to check getAvatarImageOf(String).
      Throws:
      IllegalStateException - if called outside of a request handling thread.
      See Also:
    • getAvatarDescription

      @CheckForNull public String getAvatarDescription()
      Returns the description to use for the tool tip of the avatar of this object.
      Returns:
      the avatar description or null
      Throws:
      IllegalStateException - if called outside of a request handling thread.
    • getAvatarImageOf

      @CheckForNull public String getAvatarImageOf(@NonNull String size)
      Returns the URL of the avatar of this object in the requested size or null if there is no avatar for this object. Ideally only getAvatarIconClassName() would be used, but to allow for the case where the avatar is hosted on an external server this method can be used to retrieve the avatar image.
      Parameters:
      size - the size, the following sizes must be supported: 16x16, 24x24, 32x32 and 48x48.
      Returns:
      the url or null
      Throws:
      IllegalStateException - if called outside of a request handling thread.
    • avatarIconClassNameImageOf

      @CheckForNull protected final String avatarIconClassNameImageOf(@CheckForNull String iconClassName, @NonNull String size)
      Helper method to resolve the icon image url.
      Parameters:
      iconClassName - the icon class name.
      size - the size string, e.g. 16x16, 24x24, etc.
      Returns:
      the icon image url or null
      Throws:
      IllegalStateException - if called outside of a request handling thread.
    • cachedResizedImageOf

      @NonNull protected final String cachedResizedImageOf(@NonNull String url, @NonNull String size)
      Helper method to resolve an external image, cache it and resize it to the specified size. If the external URL cannot be retrieved by Jenkins, then a randomly generated avatar will be generated using the external URL as a seed (so that the generated avatar image for any given external URL will be consistent across both Jenkins instances and restarts).
      Parameters:
      url - the URL of the image to cache.
      size - the size string, e.g. 16x16, 24x24, etc.
      Returns:
      the icon image url.
      Throws:
      IllegalStateException - if called outside of a request handling thread.
      Since:
      2.2.0
    • equals

      public abstract boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public abstract int hashCode()
      Overrides:
      hashCode in class Object