public class StructureUtil extends Object
Contains miscellaneous utility methods.
Modifier and Type | Field and Description |
---|---|
static La<com.almworks.integers.IntIterator,Integer> |
INT_ITERATOR_TO_INT |
static org.codehaus.jackson.type.TypeReference<Map<String,Object>> |
JSON_MAP |
static La<com.almworks.integers.LongIterator,Long> |
LONG_ITERATOR_TO_LONG |
static int |
MAX_PROPERTY_LENGTH |
static La<String,Long> |
STRING_LONG |
Constructor and Description |
---|
StructureUtil() |
Modifier and Type | Method and Description |
---|---|
static StringBuilder |
appendDebugIssueString(Long issue,
StringBuilder sb) |
static StringBuilder |
appendDebugIssueString(Long issueId,
String issueKey,
StringBuilder r) |
static StringBuilder |
appendDebugStructureString(long structureId,
StructureManager manager,
StringBuilder sb) |
static PermissionLevel |
applyPermissions(List<PermissionRule> permissions,
com.atlassian.jira.user.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 JAXBContext |
createJAXBContext(Class contextClass) |
static int |
createRuntimeSignature() |
static String |
debugAction(com.opensymphony.workflow.loader.ActionDescriptor action) |
static String |
debugConstant(com.atlassian.jira.issue.IssueConstant constant) |
static String |
decodeURL(String url) |
static org.codehaus.jackson.map.ObjectMapper |
defaultMapper() |
static String |
encodeURIComponent(String cmp) |
static String |
encodeURL(String url) |
static Map<String,Object> |
fromJson(String json) |
static <T> T |
fromJson(String specJson,
Class<T> expectedClass) |
static <T> T |
fromJson(String specJson,
Class<T> expectedClass,
org.codehaus.jackson.map.ObjectMapper mapper) |
static Map<String,Object> |
fromJson(String json,
org.codehaus.jackson.map.ObjectMapper mapper) |
static <T> T |
fromJson(String json,
org.codehaus.jackson.type.TypeReference<T> typeRef) |
static <T> T |
fromJson(String json,
org.codehaus.jackson.type.TypeReference<T> typeRef,
org.codehaus.jackson.map.ObjectMapper mapper) |
static <T> T |
fromMap(Map json,
Class<T> expectedClass) |
static <T> T |
fromMap(Map json,
Class<T> expectedClass,
org.codehaus.jackson.map.ObjectMapper mapper) |
static com.atlassian.jira.user.ApplicationUser |
getApplicationUserByName(String userName) |
static String |
getBaseUrl() |
static boolean |
getBooleanSystemProperty(String key,
boolean defaultValue)
Similar to
Boolean.getBoolean(String) , but with ability to specify default value if no value is specified. |
static String |
getDebugIssueKey(long issueId)
Returns issue key if possible.
|
static String |
getDebugIssueString(com.atlassian.jira.issue.Issue issue)
Returns a string representation of the issue that is used to write log messages.
|
static String |
getDebugIssueString(Long issue)
Returns a string representation of the issue that is used to write log messages.
|
static String |
getDebugRowString(long row) |
static String |
getDebugRowString(StructureRow row) |
static String |
getDebugStructureString(long structureId,
StructureManager structureManager) |
static String |
getGroupName(com.atlassian.crowd.embedded.api.Group group) |
static String |
getItemDescription(ItemIdentity itemId) |
static ItemDisplayable |
getItemDisplayable(ItemForest fragment,
StructureAttributeService attributeService) |
static ItemDisplayable |
getItemDisplayable(ItemIdentity itemId,
StructureAttributeService attributeService) |
static ItemDisplayable |
getItemDisplayable(StructureRow row,
StructureAttributeService attributeService) |
static Locale |
getJiraDefaultLocale() |
static String |
getLongProperty(com.atlassian.jira.config.properties.ApplicationProperties properties,
String name)
Reads a value previously stored in properties using setLongValue
|
static String |
getMessageWithCauseChain(Throwable t) |
static List<String> |
getMultiParameter(Map map,
String name) |
static List<Long> |
getMultiParameterLong(Map map,
String name) |
static String |
getSingleParameter(Map map,
String name) |
static boolean |
getSingleParameterBoolean(Map map,
String name) |
static Integer |
getSingleParameterInteger(Map map,
String name) |
static Long |
getSingleParameterLong(Map map,
String name) |
static String |
getText(Locale locale,
com.atlassian.jira.user.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.
|
static String |
getTextInCurrentUserLocale(String key,
Object... parameters) |
static com.atlassian.jira.user.ApplicationUser |
getUserByKey(String userKey) |
static String |
getUserKey(com.atlassian.jira.user.ApplicationUser user) |
static String |
getUserName(com.atlassian.jira.user.ApplicationUser user) |
static String |
getUserNameByKey(String userKey) |
static boolean |
isDevMode() |
static boolean |
isMutuallyExclusive(com.almworks.integers.LongList set1,
com.almworks.integers.LongList set2) |
static boolean |
isMutuallyExclusive(com.almworks.integers.LongSet set1,
com.almworks.integers.LongSet set2) |
static boolean |
isSubMap(Map<String,Object> map,
Map<String,Object> subMap) |
static String |
issueKeyOrId(com.atlassian.jira.issue.Issue issue,
Long issueId) |
static int |
iv(String v,
int defaultValue) |
static long |
lastOrZero(com.almworks.integers.LongList list)
Returns the last element of the given list if it's not empty, 0 otherwise.
|
static boolean |
listsEqual(com.almworks.integers.LongList list1,
com.almworks.integers.LongList list2)
Tests whether the given lists are equal (contain the same numbers in the same order).
|
static <T> Class<List<T>> |
listType() |
static long |
lv(String v,
long defaultValue) |
static Long |
lvn(String v) |
static <T,V> Class<Map<T,V>> |
mapType() |
static String |
migrateUserNameToUserKey(String userName) |
static int |
nn(Integer value,
int defaultValue) |
static long |
nn(Long value,
long defaultValue) |
static String |
nn(String value) |
static int |
nni(Integer value) |
static long |
nnl(Long value) |
static <T> T |
nnv(T value,
T defaultValue) |
static String |
nonBlank(String value) |
static boolean |
onlyOneIsTrue(boolean... booleans) |
static void |
setLongProperty(com.atlassian.jira.config.properties.ApplicationProperties properties,
String name,
String value)
Sets a possibly long value (template) as an application property.
|
static <T> Class<Set<T>> |
setType() |
static <T> void |
swap(List<T> list,
int a,
int b) |
static String |
toDebugJson(Object object) |
static String |
toJson(Object object) |
static String |
toJson(Object object,
org.codehaus.jackson.map.ObjectMapper mapper) |
static Map<String,Object> |
toMap(Object object) |
static Map<String,Object> |
toMap(Object object,
org.codehaus.jackson.map.ObjectMapper mapper) |
static String |
username(com.atlassian.jira.user.ApplicationUser user) |
static void |
warnExceptionIfDebug(org.slf4j.Logger log,
String message,
Throwable t) |
static org.codehaus.jackson.map.ObjectMapper |
withUnknownPropertiesMapper() |
public static final int MAX_PROPERTY_LENGTH
public static final La<com.almworks.integers.IntIterator,Integer> INT_ITERATOR_TO_INT
public static final La<com.almworks.integers.LongIterator,Long> LONG_ITERATOR_TO_LONG
public static PermissionLevel applyPermissions(List<PermissionRule> permissions, com.atlassian.jira.user.ApplicationUser user, List<Object> stack, La<Long,List<PermissionRule>> resolver, PermissionLevel pass)
public static JAXBContext createJAXBContext(Class contextClass)
@Nullable public static Long getSingleParameterLong(@Nullable Map map, @Nullable String name)
@Nullable public static Integer getSingleParameterInteger(@Nullable Map map, @Nullable String name)
public static boolean getSingleParameterBoolean(@Nullable Map map, @Nullable String name)
@Nullable public static String getSingleParameter(@Nullable Map map, @Nullable String name)
@NotNull public static List<String> getMultiParameter(@Nullable Map map, @Nullable String name)
@NotNull public static List<Long> getMultiParameterLong(@Nullable Map map, @Nullable String name)
public static void setLongProperty(com.atlassian.jira.config.properties.ApplicationProperties properties, String name, String value)
properties
- properties interfacename
- the name of the propertyvalue
- the value@NotNull public static String getLongProperty(com.atlassian.jira.config.properties.ApplicationProperties properties, String name)
properties
- application propetiesname
- the name of the property to readpublic static boolean getBooleanSystemProperty(String key, boolean defaultValue)
Boolean.getBoolean(String)
, but with ability to specify default value if no value is specified.public static long lastOrZero(com.almworks.integers.LongList list)
list
- the list of longslist
or 0 if it's empty.public static boolean listsEqual(com.almworks.integers.LongList list1, com.almworks.integers.LongList list2)
null
list.list1
- the first listlist2
- the second listtrue
if the lists are equal, false
otherwise.@Nullable public static List<PermissionRule> copyPermissionsOrNull(@Nullable Collection<? extends PermissionRule> permissions)
@NotNull public static List<PermissionRule> copyPermissions(@Nullable Collection<? extends PermissionRule> permissions)
@NotNull public static String getDebugIssueString(@Nullable Long issue)
issue
- the ID of the issuepublic static StringBuilder appendDebugIssueString(@Nullable Long issue, StringBuilder sb)
@Nullable public static String getDebugIssueKey(long issueId)
@NotNull public static String getDebugIssueString(@Nullable com.atlassian.jira.issue.Issue issue)
issue
- the issuepublic static String issueKeyOrId(@Nullable com.atlassian.jira.issue.Issue issue, @Nullable Long issueId)
null
. Otherwise, if issue ID is not null
, returns issue ID in the form "issue #123". Otherwise,
returns string "(no issue ID)".
Better suited for high-level log messages than getDebugIssueString(java.lang.Long)
in that it is easily recognizable as issue representation to JIRA admin.@NotNull public static StringBuilder appendDebugIssueString(@Nullable Long issueId, @Nullable String issueKey, StringBuilder r)
@NotNull public static StringBuilder appendDebugStructureString(long structureId, StructureManager manager, StringBuilder sb)
public static String getDebugStructureString(long structureId, StructureManager structureManager)
@NotNull public static String username(@Nullable com.atlassian.jira.user.ApplicationUser user)
public static String debugConstant(com.atlassian.jira.issue.IssueConstant constant)
public static String debugAction(com.opensymphony.workflow.loader.ActionDescriptor action)
public static String getTextInCurrentUserLocale(String key, Object... parameters)
@NotNull public static String getText(@Nullable Locale locale, @Nullable com.atlassian.jira.user.ApplicationUser user, String textKey, Object... messageParameters)
root
(neutral) locale is used.messageParameters
- can be the same as I18nHelper.getText(String, Object)
@NotNull public static Locale getJiraDefaultLocale()
public static String getUserKey(@Nullable com.atlassian.jira.user.ApplicationUser user)
@Nullable public static String getUserName(@Nullable com.atlassian.jira.user.ApplicationUser user)
@Nullable public static com.atlassian.jira.user.ApplicationUser getUserByKey(@Nullable String userKey)
@Nullable public static com.atlassian.jira.user.ApplicationUser getApplicationUserByName(@Nullable String userName)
@Nullable public static String migrateUserNameToUserKey(@Nullable String userName)
public static int createRuntimeSignature()
public static String getDebugRowString(long row)
public static String getDebugRowString(StructureRow row)
@NotNull public static String toJson(@Nullable Object object, org.codehaus.jackson.map.ObjectMapper mapper)
@Nullable public static <T> T fromJson(String specJson, Class<T> expectedClass, org.codehaus.jackson.map.ObjectMapper mapper)
@Nullable public static <T> T fromJson(String json, org.codehaus.jackson.type.TypeReference<T> typeRef)
@Nullable public static <T> T fromJson(String json, org.codehaus.jackson.type.TypeReference<T> typeRef, org.codehaus.jackson.map.ObjectMapper mapper)
@Nullable public static Map<String,Object> fromJson(String json, org.codehaus.jackson.map.ObjectMapper mapper)
@Nullable public static <T> T fromMap(Map json, Class<T> expectedClass, org.codehaus.jackson.map.ObjectMapper mapper)
@Nullable public static Map<String,Object> toMap(Object object, org.codehaus.jackson.map.ObjectMapper mapper)
public static org.codehaus.jackson.map.ObjectMapper defaultMapper()
public static org.codehaus.jackson.map.ObjectMapper withUnknownPropertiesMapper()
public static boolean onlyOneIsTrue(boolean... booleans)
public static <T> void swap(List<T> list, int a, int b)
public static void warnExceptionIfDebug(org.slf4j.Logger log, String message, Throwable t)
public static String getItemDescription(ItemIdentity itemId)
public static ItemDisplayable getItemDisplayable(ItemIdentity itemId, StructureAttributeService attributeService)
public static ItemDisplayable getItemDisplayable(StructureRow row, StructureAttributeService attributeService)
public static ItemDisplayable getItemDisplayable(ItemForest fragment, StructureAttributeService attributeService)
@Nullable public static String getGroupName(com.atlassian.crowd.embedded.api.Group group)
public static boolean isMutuallyExclusive(com.almworks.integers.LongList set1, com.almworks.integers.LongList set2)
public static boolean isMutuallyExclusive(com.almworks.integers.LongSet set1, com.almworks.integers.LongSet set2)
public static long nn(@Nullable Long value, long defaultValue)
public static int nn(@Nullable Integer value, int defaultValue)
@NotNull public static <T> T nnv(@Nullable T value, @NotNull T defaultValue)
public static long lv(String v, long defaultValue)
public static int iv(String v, int defaultValue)
public static long nnl(Long value)
public static int nni(Integer value)
@NotNull public static String getBaseUrl()
@Internal public static boolean isDevMode()
@NotNull public static String nonBlank(@Nullable String value) throws IllegalArgumentException
IllegalArgumentException
Copyright © 2019 ALM Works. All Rights Reserved.