Class EmojiManager

java.lang.Object
net.fellbaum.jemoji.EmojiManager

public final class EmojiManager extends Object
  • Method Details

    • getEmoji

      public static Optional<Emoji> getEmoji(String emoji)
      Returns the emoji for the given Unicode.
      Parameters:
      emoji - The Unicode of the emoji.
      Returns:
      The emoji.
    • isEmoji

      public static boolean isEmoji(String emoji)
      Check if the given string is an emoji.
      Parameters:
      emoji - The emoji to check.
      Returns:
      True if the given string is an emoji.
    • getAllEmojis

      public static Set<Emoji> getAllEmojis()
      Gets all emojis.
      Returns:
      A set of all emojis.
    • getAllEmojisGrouped

      public static Map<EmojiGroup,Set<Emoji>> getAllEmojisGrouped()
      Gets all emojis mapped to their group.
      Returns:
      A map of all emojis mapped to their group.
    • getAllEmojisSubGrouped

      public static Map<EmojiSubGroup,Set<Emoji>> getAllEmojisSubGrouped()
      Gets all emojis mapped to their subgroup.
      Returns:
      A map of all emojis mapped to their subgroup.
    • getAllEmojisByGroup

      public static Set<Emoji> getAllEmojisByGroup(EmojiGroup group)
      Gets all emojis that are part of the given group.
      Parameters:
      group - The group to get the emojis for.
      Returns:
      A set of all emojis that are part of the given group.
    • getAllEmojisBySubGroup

      public static Set<Emoji> getAllEmojisBySubGroup(EmojiSubGroup subgroup)
      Gets all emojis that are part of the given subgroup.
      Parameters:
      subgroup - The subgroup to get the emojis for.
      Returns:
      A set of all emojis that are part of the given subgroup.
    • getAllEmojisLengthDescending

      public static List<Emoji> getAllEmojisLengthDescending()
      Gets all emojis in descending order by their char length.
      Returns:
      A list of all emojis.
    • getByHtmlDecimal

      public static Optional<Emoji> getByHtmlDecimal(String htmlDecimal)
      Gets an emoji for the given HTML decimal i.e. &#128077; (thumbsup emoji) if present.
      Parameters:
      htmlDecimal - The HTML decimal of the emoji.
      Returns:
      The emoji.
    • getByHtmlHexadecimal

      public static Optional<Emoji> getByHtmlHexadecimal(String htmlHexadecimal)
      Gets an emoji for the given HTML hexadecimal i.e. &#x1F44D; (thumbsup emoji) if present.
      Parameters:
      htmlHexadecimal - The HTML hexadecimal of the emoji.
      Returns:
      The emoji.
    • getByUrlEncoded

      public static Optional<Emoji> getByUrlEncoded(String urlEncodedEmoji)
      Gets an emoji for the given url encoded emoji i.e. %F0%9F%91%8D (thumbsup emoji) if present.
      Parameters:
      urlEncodedEmoji - The HTML hexadecimal of the emoji.
      Returns:
      The emoji.
    • getByAlias

      public static Optional<List<Emoji>> getByAlias(String alias)
      Gets an emoji for the given alias i.e. :thumbsup: if present.
      Parameters:
      alias - The alias of the emoji.
      Returns:
      The emoji.
    • getByDiscordAlias

      public static Optional<Emoji> getByDiscordAlias(String alias)
      Gets an emoji for the given Discord alias i.e. :thumbsup: if present.
      Parameters:
      alias - The Discord alias of the emoji.
      Returns:
      The emoji.
    • getByGithubAlias

      public static Optional<Emoji> getByGithubAlias(String alias)
      Gets an emoji for the given GitHub alias i.e. :thumbsup: if present.
      Parameters:
      alias - The GitHub alias of the emoji.
      Returns:
      The emoji.
    • getBySlackAlias

      public static Optional<Emoji> getBySlackAlias(String alias)
      Gets an emoji for the given Slack alias i.e. :thumbsup: if present.
      Parameters:
      alias - The Slack alias of the emoji.
      Returns:
      The emoji.
    • getEmojiPattern

      public static Pattern getEmojiPattern()
      Gets the pattern checking for all emojis.
      Returns:
      The pattern for all emojis.
    • containsAnyEmoji

      public static boolean containsAnyEmoji(String text)
      Checks if the given text contains emojis.
      Parameters:
      text - The text to check.
      Returns:
      True if the given text contains emojis.
    • containsAnyEmoji

      public static boolean containsAnyEmoji(String text, EnumSet<EmojiType> emojiType)
      Checks if the given text contains emojis.
      Parameters:
      text - The text to check.
      emojiType - The type of the emoji appearance in the string which should be checked against.
      Returns:
      True if the given text contains emojis.
    • extractEmojis

      public static Set<Emoji> extractEmojis(String text)
      Extracts all emojis from the given text.
      Parameters:
      text - The text to extract emojis from.
      Returns:
      A list of emojis.
    • extractEmojis

      public static Set<Emoji> extractEmojis(String text, EnumSet<EmojiType> emojiType)
      Extracts all emojis from the given text.
      Parameters:
      text - The text to extract emojis from.
      emojiType - The type of the emoji appearance in the string which should be extracted.
      Returns:
      A list of emojis.
    • extractEmojisInOrder

      public static List<Emoji> extractEmojisInOrder(String text)
      Extracts all emojis from the given text in the order they appear.
      Parameters:
      text - The text to extract emojis from.
      Returns:
      A list of emojis.
    • extractEmojisInOrder

      public static List<Emoji> extractEmojisInOrder(String text, EnumSet<EmojiType> emojiType)
      Extracts all emojis from the given text in the order they appear.
      Parameters:
      text - The text to extract emojis from.
      emojiType - The type of the emoji appearance in the string which should be extracted.
      Returns:
      A list of emojis.
    • extractEmojisInOrderWithIndex

      public static List<IndexedEmoji> extractEmojisInOrderWithIndex(String text)
      Extracts all emojis from the given text in the order they appear.
      Parameters:
      text - The text to extract emojis from.
      Returns:
      A list of indexed emojis.
    • extractEmojisInOrderWithIndex

      public static List<IndexedEmoji> extractEmojisInOrderWithIndex(String text, EnumSet<EmojiType> emojiType)
      Extracts all emojis from the given text in the order they appear.
      Parameters:
      text - The text to extract emojis from.
      emojiType - The type of the emoji appearance in the string which should be extracted.
      Returns:
      A list of indexed emojis.
    • removeAllEmojis

      public static String removeAllEmojis(String text)
      Removes all emojis from the given text.
      Parameters:
      text - The text to remove emojis from.
      Returns:
      The text without emojis.
    • removeAllEmojis

      public static String removeAllEmojis(String text, EnumSet<EmojiType> emojiType)
      Removes all emojis from the given text.
      Parameters:
      text - The text to remove emojis from.
      emojiType - The type of the emoji appearance in the string which should be removed.
      Returns:
      The text without emojis.
    • removeEmojis

      public static String removeEmojis(String text, Emoji... emojisToRemove)
      Removes the given emojis from the given text.
      Parameters:
      text - The text to remove emojis from.
      emojisToRemove - The emojis to remove.
      Returns:
      The text without the given emojis.
    • removeEmojis

      public static String removeEmojis(String text, Collection<Emoji> emojisToRemove)
      Removes the given emojis from the given text.
      Parameters:
      text - The text to remove emojis from.
      emojisToRemove - The emojis to remove.
      Returns:
      The text without the given emojis.
    • removeEmojis

      public static String removeEmojis(String text, Collection<Emoji> emojisToRemove, EnumSet<EmojiType> emojiType)
      Removes the given emojis from the given text.
      Parameters:
      text - The text to remove emojis from.
      emojisToRemove - The emojis to remove.
      emojiType - The type of the emoji appearance in the string which should be removed.
      Returns:
      The text without the given emojis.
    • removeAllEmojisExcept

      public static String removeAllEmojisExcept(String text, Emoji... emojisToKeep)
      Removes all emojis except the given emojis from the given text.
      Parameters:
      text - The text to remove emojis from.
      emojisToKeep - The emojis to keep.
      Returns:
      The text with only the given emojis.
    • removeAllEmojisExcept

      public static String removeAllEmojisExcept(String text, Collection<Emoji> emojisToKeep)
      Removes all emojis except the given emojis from the given text.
      Parameters:
      text - The text to remove emojis from.
      emojisToKeep - The emojis to keep.
      Returns:
      The text with only the given emojis.
    • removeAllEmojisExcept

      public static String removeAllEmojisExcept(String text, Collection<Emoji> emojisToKeep, EnumSet<EmojiType> emojiType)
      Removes all emojis except the given emojis from the given text.
      Parameters:
      text - The text to remove emojis from.
      emojisToKeep - The emojis to keep.
      emojiType - The type of the emoji appearance in the string which should be removed.
      Returns:
      The text with only the given emojis.
    • replaceAllEmojis

      public static String replaceAllEmojis(String text, String replacementString)
      Replaces all emojis in the text with the given replacement string.
      Parameters:
      text - The text to replace emojis from.
      replacementString - The replacement string.
      Returns:
      The text with all emojis replaced.
    • replaceAllEmojis

      public static String replaceAllEmojis(String text, String replacementString, EnumSet<EmojiType> emojiType)
      Replaces all emojis in the text with the given replacement string.
      Parameters:
      text - The text to replace emojis from.
      replacementString - The replacement string.
      emojiType - The type of the emoji appearance in the string which should be replaced.
      Returns:
      The text with all emojis replaced.
    • replaceAllEmojis

      public static String replaceAllEmojis(String text, Function<Emoji,String> replacementFunction)
      Replaces all emojis in the text with the given replacement function.
      Parameters:
      text - The text to replace emojis from.
      replacementFunction - The replacement function.
      Returns:
      The text with all emojis replaced.
    • replaceAllEmojis

      public static String replaceAllEmojis(String text, Function<Emoji,String> replacementFunction, EnumSet<EmojiType> emojiType)
      Replaces all emojis in the text with the given replacement function.
      Parameters:
      text - The text to replace emojis from.
      replacementFunction - The replacement function.
      emojiType - The type of the emoji appearance in the string which should be replaced.
      Returns:
      The text with all emojis replaced.
    • replaceEmojis

      public static String replaceEmojis(String text, String replacementString, Collection<Emoji> emojisToReplace)
      Replaces the given emojis with the given replacement string.
      Parameters:
      text - The text to replace emojis from.
      replacementString - The replacement string.
      emojisToReplace - The emojis to replace.
      Returns:
      The text with the given emojis replaced.
    • replaceEmojis

      public static String replaceEmojis(String text, String replacementString, Collection<Emoji> emojisToReplace, EnumSet<EmojiType> emojiType)
      Replaces the given emojis with the given replacement string.
      Parameters:
      text - The text to replace emojis from.
      replacementString - The replacement string.
      emojisToReplace - The emojis to replace.
      emojiType - The type of the emoji appearance in the string which should be replaced.
      Returns:
      The text with the given emojis replaced.
    • replaceEmojis

      public static String replaceEmojis(String text, String replacementString, Emoji... emojisToReplace)
      Replaces the given emojis with the given replacement string.
      Parameters:
      text - The text to replace emojis from.
      replacementString - The replacement string.
      emojisToReplace - The emojis to replace.
      Returns:
      The text with the given emojis replaced.
    • replaceEmojis

      public static String replaceEmojis(String text, Function<Emoji,String> replacementFunction, Collection<Emoji> emojisToReplace)
      Replaces all emojis in the text with the given replacement function.
      Parameters:
      text - The text to replace emojis from.
      replacementFunction - The replacement function.
      emojisToReplace - The emojis to replace.
      Returns:
      The text with all emojis replaced.
    • replaceEmojis

      public static String replaceEmojis(String text, Function<Emoji,String> replacementFunction, Collection<Emoji> emojisToReplace, EnumSet<EmojiType> emojiType)
      Replaces all emojis in the text with the given replacement function.
      Parameters:
      text - The text to replace emojis from.
      replacementFunction - The replacement function.
      emojisToReplace - The emojis to replace.
      emojiType - The type of the emoji appearance in the string which should be replaced.
      Returns:
      The text with all emojis replaced.
    • replaceAliases

      public static String replaceAliases(String text, BiFunction<String,List<Emoji>,String> replacementFunction)
      Replaces all aliases in the text with the given replacement function.
      Parameters:
      text - The text to replace aliases from.
      replacementFunction - A non-empty list. Always contains at least one emoji, but there may be more than 1 available for one alias. Therefore, it's up to you to decide which one you take.

      For example, when replacing the alias ":beach_umbrella:", these two emojis will be available. {emoji='🏖️', unicode='🏖️', discordAliases=[:beach:, :beach_with_umbrella:], githubAliases=[:beach_umbrella:], slackAliases=[:beach_with_umbrella:], hasFitzpatrick=false, hasHairStyle=false, version=0.7, qualification=FULLY_QUALIFIED, description='beach with umbrella', group=TRAVEL_AND_PLACES, subgroup=PLACE_GEOGRAPHIC, hasVariationSelectors=false, allAliases=[:beach:, :beach_umbrella:, :beach_with_umbrella:]}, {emoji='⛱️', unicode='⛱️', discordAliases=[:beach_umbrella:, :umbrella_on_ground:], githubAliases=[:parasol_on_ground:], slackAliases=[:umbrella_on_ground:], hasFitzpatrick=false, hasHairStyle=false, version=0.7, qualification=FULLY_QUALIFIED, description='umbrella on ground', group=TRAVEL_AND_PLACES, subgroup=SKY_AND_WEATHER, hasVariationSelectors=false, allAliases=[:beach_umbrella:, :umbrella_on_ground:, :parasol_on_ground:]}

      Returns:
      The text with the aliases replaced.
    • extractAliases

      public static Set<String> extractAliases(String text)
      Extracts all aliases from the given text.
      Parameters:
      text - The text to extract aliases from.
      Returns:
      A set of aliases.
    • extractAliasesInOrder

      public static List<String> extractAliasesInOrder(String text)
      Extracts all aliases from the given text in the order they appear.
      Parameters:
      text - The text to extract aliases from.
      Returns:
      A list of aliases.
    • extractAliasesInOrderWithIndex

      public static List<IndexedAlias> extractAliasesInOrderWithIndex(String text)
      Extracts all aliases from the given text in the order they appear.
      Parameters:
      text - The text to extract aliases from.
      Returns:
      A list of indexed aliases.