Class StructureUtil
Object
StructureUtil
Contains miscellaneous utility methods.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringBuilderappendDebugIssueString(Long issue, StringBuilder sb) static StringBuilderappendDebugIssueString(Long issueId, String issueKey, StringBuilder r) static StringBuilderappendDebugStructureString(long structureId, StructureManager manager, StringBuilder sb) static PermissionLevelapplyPermissions(List<PermissionRule> permissions, ApplicationUser user, List<Object> stack, La<Long, List<PermissionRule>> resolver, PermissionLevel pass) static List<PermissionRule>copyPermissions(Collection<? extends PermissionRule> permissions) static List<PermissionRule>copyPermissionsOrNull(Collection<? extends PermissionRule> permissions) static JAXBContextcreateJAXBContext(Class contextClass) static intstatic StringdebugAction(ActionDescriptor action) static StringdebugConstant(IssueConstant constant) static Stringstatic StringencodeURIComponent(String cmp) static Stringstatic <T> Tstatic ApplicationUsergetApplicationUserByName(String userName) static Stringstatic booleangetBooleanSystemProperty(String key, boolean defaultValue) Similar toBoolean.getBoolean(String), but with ability to specify default value if no value is specified.static <T> List<T>getCommaSeparatedParameter(Map map, String name, Function<String, T> converter) static StringgetDebugIssueKey(long issueId) Returns issue key if possible.static StringgetDebugIssueString(Issue issue) Returns a string representation of the issue that is used to write log messages.static StringgetDebugIssueString(Long issue) Returns a string representation of the issue that is used to write log messages.static StringgetDebugRowString(long row) static Stringstatic StringgetDebugStructureString(long structureId, StructureManager structureManager) static StringgetGroupName(Group group) static StringgetItemDescription(ItemIdentity itemId) static ItemDisplayablegetItemDisplayable(ItemIdentity itemId, StructureAttributeService attributeService) static ItemDisplayablegetItemDisplayable(StructureRow row, StructureAttributeService attributeService) static Map<ItemIdentity,ItemDisplayable> getItemDisplayable(Collection<ItemIdentity> itemIds, StructureAttributeService attributeService) static Localestatic StringgetLongProperty(ApplicationProperties properties, String name) Reads a value previously stored in properties using setLongValuestatic StringgetMultiParameter(Map map, String name) getMultiParameterLong(Map map, String name) static Longstatic StringgetSingleParameter(Map map, String name) static booleangetSingleParameterBoolean(Map map, String name) static IntegergetSingleParameterInteger(Map map, String name) static LonggetSingleParameterLong(Map map, String name) static Stringstatic StringFormats the text taken from the i18n bundle with the specified parameters in the locale that is selected as follows: If locale is not null, it is used. Otherwise, if user is not null, the user locale (set up in the user preferences) is used. If both locale and user are null, JIRA default locale is used.static StringgetTextInCurrentUserLocale(I18nText i18nText) static StringgetTextInCurrentUserLocale(String key, Object... parameters) static ApplicationUsergetUserByKey(String userKey) static StringgetUserKey(ApplicationUser user) static StringgetUserName(ApplicationUser user) static StringgetUserNameByKey(String userKey) static booleanstatic booleanisMutuallyExclusive(LongList list1, LongList list2) static booleanisMutuallyExclusive(LongSet set1, LongSet set2) static booleanstatic StringissueKeyOrId(Issue issue, Long issueId) static intstatic Integerstatic longlastOrZero(LongList list) Returns the last element of the given list if it's not empty, 0 otherwise.static booleanlistsEqual(LongList list1, LongList list2) Tests whether the given lists are equal (contain the same numbers in the same order).listType()static longstatic LongmapType()static <T> Supplier<T>memoize(Supplier<T> supplier) Not thread safestatic StringmigrateUserNameToUserKey(String userName) static intstatic longstatic Stringstatic intstatic longstatic <T> Tnnv(T value, T defaultValue) static Stringstatic booleanonlyOneIsTrue(boolean... booleans) static voidsetLongProperty(ApplicationProperties properties, String name, String value) Sets a possibly long value (template) as an application property.setType()static <T> voidstatic StringtoDebugJson(Object object) static Stringstatic Stringusername(ApplicationUser user) static voidwarnExceptionIfDebug(Logger log, String message, Throwable t)
-
Field Details
-
MAX_PROPERTY_LENGTH
public static final int MAX_PROPERTY_LENGTH- See Also:
-
STRING_LONG
-
INT_ITERATOR_TO_INT
-
LONG_ITERATOR_TO_LONG
-
-
Constructor Details
-
StructureUtil
public StructureUtil()
-
-
Method Details
-
applyPermissions
public static PermissionLevel applyPermissions(List<PermissionRule> permissions, ApplicationUser user, List<Object> stack, La<Long, List<PermissionRule>> resolver, PermissionLevel pass) -
createJAXBContext
-
getSingleParameterLong
-
getSingleParameterInteger
-
getSingleParameterBoolean
-
getSingleParameter
-
getSingleString
-
getSingleLong
-
getStringList
-
getMultiParameter
-
getMultiParameterLong
-
getCommaSeparatedParameter
-
setLongProperty
Sets a possibly long value (template) as an application property. Because properties may be limited to 255 characters, this method breaks up long property into several properties each no longer than allowed.- Parameters:
properties- properties interfacename- the name of the propertyvalue- the value
-
getLongProperty
Reads a value previously stored in properties using setLongValue- Parameters:
properties- application propetiesname- the name of the property to read- Returns:
- property value or an empty string
-
getBooleanSystemProperty
Similar toBoolean.getBoolean(String), but with ability to specify default value if no value is specified. -
lastOrZero
public static long lastOrZero(LongList list) Returns the last element of the given list if it's not empty, 0 otherwise.- Parameters:
list- the list of longs- Returns:
- last value of
listor 0 if it's empty.
-
listsEqual
public static boolean listsEqual(LongList list1, LongList list2) Tests whether the given lists are equal (contain the same numbers in the same order). An empty list is considered equal to anulllist.- Parameters:
list1- the first listlist2- the second list- Returns:
trueif the lists are equal,falseotherwise.
-
copyPermissionsOrNull
@Nullable public static List<PermissionRule> copyPermissionsOrNull(@Nullable Collection<? extends PermissionRule> permissions) -
copyPermissions
@NotNull public static List<PermissionRule> copyPermissions(@Nullable Collection<? extends PermissionRule> permissions) -
getDebugIssueString
Returns a string representation of the issue that is used to write log messages. Writes issue ID and, if possible, issue key.- Parameters:
issue- the ID of the issue- Returns:
- string that can be used in output
-
appendDebugIssueString
-
getDebugIssueKey
Returns issue key if possible. Use for debug output. -
getDebugIssueString
Returns a string representation of the issue that is used to write log messages. Writes issue ID and, if possible, issue key.- Parameters:
issue- the issue- Returns:
- string that can be used in output
-
issueKeyOrId
- Returns:
- issue key if the issue object is not
null. Otherwise, if issue ID is notnull, returns issue ID in the form "issue #123". Otherwise, returns string "(no issue ID)". Better suited for high-level log messages thangetDebugIssueString(java.lang.Long)in that it is easily recognizable as issue representation to JIRA admin.
-
appendDebugIssueString
@NotNull public static StringBuilder appendDebugIssueString(@Nullable Long issueId, @Nullable String issueKey, StringBuilder r) -
appendDebugStructureString
@NotNull public static StringBuilder appendDebugStructureString(long structureId, StructureManager manager, StringBuilder sb) -
getDebugStructureString
-
username
-
debugConstant
-
debugAction
-
getTextInCurrentUserLocale
-
getTextInCurrentUserLocale
-
getText
@NotNull public static String getText(@Nullable Locale locale, @Nullable ApplicationUser user, String textKey, Object... messageParameters) Formats the text taken from the i18n bundle with the specified parameters in the locale that is selected as follows:- If locale is not null, it is used.
- Otherwise, if user is not null, the user locale (set up in the user preferences) is used.
- If both locale and user are null, JIRA default locale is used. In a highly unlikely
event when JIRA application parameters are inaccessible,
root(neutral) locale is used.
- Parameters:
messageParameters- can be the same asI18nHelper.getText(String, Object)
-
getJiraDefaultLocale
-
getUserKey
-
getUserName
-
getUserByKey
-
getApplicationUserByName
-
getUserNameByKey
-
migrateUserNameToUserKey
-
createRuntimeSignature
public static int createRuntimeSignature()- Returns:
- a fairly random number that is used to identify the scope of some other data for external components with longer lifecycle (such as browsers or other addons). The signature is retrieved once per component lifecycle and all other data it provides is valid only within the same signature.
-
getDebugRowString
-
getDebugRowString
-
toJson
-
fromJson
-
fromJson
-
toMap
-
setType
-
mapType
-
listType
-
onlyOneIsTrue
public static boolean onlyOneIsTrue(boolean... booleans) -
swap
-
warnExceptionIfDebug
-
getMessageWithCauseChain
-
getItemDescription
-
getItemDisplayable
@NotNull public static ItemDisplayable getItemDisplayable(@NotNull ItemIdentity itemId, StructureAttributeService attributeService) -
getItemDisplayable
@NotNull public static ItemDisplayable getItemDisplayable(@NotNull StructureRow row, StructureAttributeService attributeService) -
getItemDisplayable
@NotNull public static Map<ItemIdentity,ItemDisplayable> getItemDisplayable(@NotNull Collection<ItemIdentity> itemIds, StructureAttributeService attributeService) -
getGroupName
-
isMutuallyExclusive
public static boolean isMutuallyExclusive(LongList list1, LongList list2) -
isMutuallyExclusive
public static boolean isMutuallyExclusive(LongSet set1, LongSet set2) -
toDebugJson
-
nn
-
nn
-
nnv
@NotNull public static <T> T nnv(@Nullable T value, @NotNull T defaultValue) -
lv
-
iv
-
lvn
-
ivn
-
nn
-
nnl
-
nni
-
getBaseUrl
-
decodeURL
-
encodeURL
-
encodeURIComponent
-
isSubMap
-
isDevMode
@Internal public static boolean isDevMode() -
nonBlank
- Throws:
IllegalArgumentException
-
memoize
public static <T> Supplier<T> memoize(Supplier<T> supplier) Not thread safe
-