Class FileNameBasedVersionedAttachmentsList

java.lang.Object
com.atlassian.jira.bc.issue.attachment.FileNameBasedVersionedAttachmentsList
All Implemented Interfaces:
VersionedAttachmentsList

public class FileNameBasedVersionedAttachmentsList extends Object implements VersionedAttachmentsList
This implementation wraps a list of attachments and adds the concept of attachment 'versions' by grouping attachments that have the same filename as versions of the same file.

It stores this 'version' information when constructed by building up a Map with keys for every distinct file name in the underlying List of attachments. Then, each key's value is a TreeSet of attachments which have that filename.

Since:
v4.2
  • Constructor Details

    • FileNameBasedVersionedAttachmentsList

      public FileNameBasedVersionedAttachmentsList(List<Attachment> attachments)
  • Method Details

    • asList

      public List<Attachment> asList()
      Description copied from interface: VersionedAttachmentsList
      Returns the underlying list of attachments.
      Specified by:
      asList in interface VersionedAttachmentsList
      Returns:
      A List of Attachment.
    • isLatestVersion

      public boolean isLatestVersion(Attachment attachment)
      Determines whether the specified attachment is the latest file uploaded amongst the group of files with the same name in the underlying list.
      Specified by:
      isLatestVersion in interface VersionedAttachmentsList
      Parameters:
      attachment - The attachment in play. Should not be null.
      Returns:
      true if this is the latest (or only) file with this name; otherwise false.