com.atlassian.jira.bc.issue.attachment
Class FileNameBasedVersionedAttachmentsList

java.lang.Object
  extended by 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 Summary
FileNameBasedVersionedAttachmentsList(List<Attachment> attachments)
           
 
Method Summary
 List<Attachment> asList()
          Returns the underlying list of attachments.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileNameBasedVersionedAttachmentsList

public FileNameBasedVersionedAttachmentsList(List<Attachment> attachments)
Method Detail

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.


Copyright © 2002-2012 Atlassian. All Rights Reserved.