Class ItemIdentity
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
ItemIdentity.LongIdentity,ItemIdentity.StringIdentity
ItemIdentity represents an item, a core concept in Structure's architecture.
An item is an abstract notion that generalizes everything that can be put into a structure. Issues, projects, users and other JIRA objects — all can be represented as items. Structures themselves may be represented as items. Structure can be extended and new types of items can be added to it — for example, Structure.Pages extension adds "Confluence page" item type.
Because of such diversity, there's no single class that represents an item in the low-level API. Instead,
there's ItemIdentity which represents the only single property that each item must have — its
unique ID.
Anatomy of the item ID
Each ItemIdentity is a pair of item type and item id within that
type.
Item type is nothing else but the complete module key of the <structure-item-type> module, which
supports this item type. Main item types are listed in CoreItemTypes.
The actual item ID can be either long or String. Numeric item IDs are used whenever possible,
as that allows Structure to save consumed memory and speed up calculations. Issues, Folders, Projects, Sprints
and most other items are identified with long ID.
Text item IDs are used in other cases. For example, Users and Special Folders are represented with
String IDs.
Item type does not prescribe whether IDs are long or string based. For one type there might be issues with long IDs and string IDs.
Uniqueness
It is important to remember that an item ID is unique only within a single instance of JIRA (or within a single cluster running JIRA Data Center). It is not globally unique. So when synchronizing multiple JIRAs or when restoring Structure data on another instance, all items must be mapped to the new instance.
Value Range
- Both item type and string ID must not be null or empty and must not exceed 190 characters.
- There are no limit on the value of long ID, it can be 0.
Canonical notation
ItemIdentity can be serialized into a String by calling toString() on it. The serialized
form is either:
<itemType>/<itemID>for long-based identities, for example:com.almworks.jira.structure:type-issue/10000<itemType>//<itemID>for string-based identities, for example:com.almworks.jira.structure:type-user//admin
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classRepresents long-based ID.static final classRepresents string-based ID. -
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionReturns item type.longGets the long ID from a long-basedItemIdentity.Gets the string ID from a string-basedItemIdentity.booleanisLongId()Returnstrueif this ID is long-based.booleanReturnstrueif this ID is string-based.static ItemIdentityCreates a new long-based ID.static ItemIdentityParses canonical string representation of the item ID, which can be retrieved withtoString()method.static ItemIdentityCreates a new string-based ID.abstract String
-
Field Details
-
ITEM_ZERO
Represents non-existing item.
-
-
Method Details
-
getItemType
Returns item type. -
isStringId
public boolean isStringId()Returnstrueif this ID is string-based. -
getStringId
Gets the string ID from a string-basedItemIdentity.- Returns:
- string ID, not null, not empty
- Throws:
UnsupportedOperationException- if this is not a string-based ID
-
isLongId
public boolean isLongId()Returnstrueif this ID is long-based. -
getLongId
public long getLongId()Gets the long ID from a long-basedItemIdentity.- Returns:
- long ID, not
0 - Throws:
UnsupportedOperationException- if this is not a long-based ID
-
stringId
Creates a new string-based ID.- Parameters:
itemType- item typestringId- item ID- Returns:
- identity
- Throws:
IllegalArgumentException- if the parameters are invalid
-
longId
Creates a new long-based ID.- Parameters:
itemType- item typelongId- item ID- Returns:
- identity
- Throws:
IllegalArgumentException- if the parameters are invalid
-
parse
Parses canonical string representation of the item ID, which can be retrieved withtoString()method.- Parameters:
id- string representation of the item ID.- Returns:
- identity
- Throws:
ParseException- if there were errors parsing the string or if the parsed parameters were invalids
-
toSimplifiedString
-