com.atlassian.bitbucket.user.UserMentionScanner |
Handles rendering and parsing user mention strings in texts.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
UserMentionScanner.UserMention | Represents the location and content of a user mention in the text. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns all mentioned
user names in the text. | |||||||||||
Calls
callback for each user mention found in text . | |||||||||||
Renders the full user mention for a
user name . | |||||||||||
Replaces all user mentions with the string returned from the passed
replacementFunction . |
Returns all mentioned user names
in the text.
Note that the case of the user name returned matches the case used in the text and might not be identical to the
case of the ApplicationUser's name
.
text | text to search for user mentions |
---|---|
maxMentions | maximum size of the returned set |
user names
mentioned
Calls callback
for each user mention found in text
.
text | text to search for user mentions |
---|---|
callback | callback that gets called for every user mention found |
Replaces all user mentions with the string returned from the passed replacementFunction
.
Return types for both the replacementFunction
as well as this method are Optional so the calling
code can perform more efficient operations when no replacements have taken place.
Example usage:
String replacedText = userMentionScanner.replaceMentions(text, mention ->
Optional.of(userMentionScanner.renderMention(mention.getUsername().replace("_", "-"))))
.orElse(text);
text | text to search and replace user mentions in |
---|---|
replacementFunction | function that optionally returns a replacement for the full mention of the user |
empty()
if no replacement took place