Skip to content

Commit

Permalink
Added methods to get EmojiGroup/EmojiSubGroup of the EmojiSubGroup/Em…
Browse files Browse the repository at this point in the history
…ojiGroup
  • Loading branch information
felldo committed Sep 22, 2023
1 parent 3f61f59 commit 376c789
Show file tree
Hide file tree
Showing 2 changed files with 120 additions and 102 deletions.
11 changes: 11 additions & 0 deletions lib/src/main/java/net/fellbaum/jemoji/EmojiGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
import com.fasterxml.jackson.annotation.JsonCreator;

import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import java.util.stream.Collectors;

/**
* Represents an emoji group.
Expand Down Expand Up @@ -46,6 +48,15 @@ public static List<EmojiGroup> getGroups() {
return EMOJI_GROUPS;
}

/**
* Gets all emoji subgroups of this group.
*
* @return All emoji subgroups of this group
*/
public EnumSet<EmojiSubGroup> getEmojiSubGroups() {
return EnumSet.copyOf(EmojiSubGroup.getSubGroups().stream().filter(subgroup -> subgroup.getGroup() == this).collect(Collectors.toList()));
}

/**
* Gets the emoji group for the given name.
*
Expand Down
211 changes: 109 additions & 102 deletions lib/src/main/java/net/fellbaum/jemoji/EmojiSubGroup.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,115 +8,118 @@
/**
* Represents an emoji sub group.
*/
@SuppressWarnings("unused")
public enum EmojiSubGroup {

ALPHANUM("alphanum"),
ANIMAL_AMPHIBIAN("animal-amphibian"),
ANIMAL_BIRD("animal-bird"),
ANIMAL_BUG("animal-bug"),
ANIMAL_MAMMAL("animal-mammal"),
ANIMAL_MARINE("animal-marine"),
ANIMAL_REPTILE("animal-reptile"),
ARROW("arrow"),
ARTS_CRAFTS("arts & crafts"),
AV_SYMBOL("av-symbol"),
AWARD_MEDAL("award-medal"),
BODY_PARTS("body-parts"),
BOOK_PAPER("book-paper"),
CAT_FACE("cat-face"),
CLOTHING("clothing"),
COMPUTER("computer"),
COUNTRY_FLAG("country-flag"),
CURRENCY("currency"),
DISHWARE("dishware"),
DRINK("drink"),
EMOTION("emotion"),
EVENT("event"),
FACE_AFFECTION("face-affection"),
FACE_CONCERNED("face-concerned"),
FACE_COSTUME("face-costume"),
FACE_GLASSES("face-glasses"),
FACE_HAND("face-hand"),
FACE_HAT("face-hat"),
FACE_NEGATIVE("face-negative"),
FACE_NEUTRAL_SKEPTICAL("face-neutral-skeptical"),
FACE_SLEEPY("face-sleepy"),
FACE_SMILING("face-smiling"),
FACE_TONGUE("face-tongue"),
FACE_UNWELL("face-unwell"),
FAMILY("family"),
FLAG("flag"),
FOOD_ASIAN("food-asian"),
FOOD_FRUIT("food-fruit"),
FOOD_MARINE("food-marine"),
FOOD_PREPARED("food-prepared"),
FOOD_SWEET("food-sweet"),
FOOD_VEGETABLE("food-vegetable"),
GAME("game"),
GENDER("gender"),
GEOMETRIC("geometric"),
HAIR_STYLE("hair-style"),
HANDS("hands"),
HAND_FINGERS_CLOSED("hand-fingers-closed"),
HAND_FINGERS_OPEN("hand-fingers-open"),
HAND_FINGERS_PARTIAL("hand-fingers-partial"),
HAND_PROP("hand-prop"),
HAND_SINGLE_FINGER("hand-single-finger"),
HEART("heart"),
HOTEL("hotel"),
HOUSEHOLD("household"),
KEYCAP("keycap"),
LIGHT_VIDEO("light & video"),
LOCK("lock"),
MAIL("mail"),
MATH("math"),
MEDICAL("medical"),
MONEY("money"),
MONKEY_FACE("monkey-face"),
MUSIC("music"),
MUSICAL_INSTRUMENT("musical-instrument"),
OFFICE("office"),
OTHER_OBJECT("other-object"),
OTHER_SYMBOL("other-symbol"),
PERSON("person"),
PERSON_ACTIVITY("person-activity"),
PERSON_FANTASY("person-fantasy"),
PERSON_GESTURE("person-gesture"),
PERSON_RESTING("person-resting"),
PERSON_ROLE("person-role"),
PERSON_SPORT("person-sport"),
PERSON_SYMBOL("person-symbol"),
PHONE("phone"),
PLACE_BUILDING("place-building"),
PLACE_GEOGRAPHIC("place-geographic"),
PLACE_MAP("place-map"),
PLACE_OTHER("place-other"),
PLACE_RELIGIOUS("place-religious"),
PLANT_FLOWER("plant-flower"),
PLANT_OTHER("plant-other"),
PUNCTUATION("punctuation"),
RELIGION("religion"),
SCIENCE("science"),
SKIN_TONE("skin-tone"),
SKY_WEATHER("sky & weather"),
SOUND("sound"),
SPORT("sport"),
SUBDIVISION_FLAG("subdivision-flag"),
TIME("time"),
TOOL("tool"),
TRANSPORT_AIR("transport-air"),
TRANSPORT_GROUND("transport-ground"),
TRANSPORT_SIGN("transport-sign"),
TRANSPORT_WATER("transport-water"),
WARNING("warning"),
WRITING("writing"),
ZODIAC("zodiac");
ALPHANUM("alphanum", EmojiGroup.SYMBOLS),
ANIMAL_AMPHIBIAN("animal-amphibian", EmojiGroup.ANIMALS_AND_NATURE),
ANIMAL_BIRD("animal-bird", EmojiGroup.ANIMALS_AND_NATURE),
ANIMAL_BUG("animal-bug", EmojiGroup.ANIMALS_AND_NATURE),
ANIMAL_MAMMAL("animal-mammal", EmojiGroup.ANIMALS_AND_NATURE),
ANIMAL_MARINE("animal-marine", EmojiGroup.ANIMALS_AND_NATURE),
ANIMAL_REPTILE("animal-reptile", EmojiGroup.ANIMALS_AND_NATURE),
ARROW("arrow", EmojiGroup.SYMBOLS),
ARTS_CRAFTS("arts & crafts", EmojiGroup.ACTIVITIES),
AV_SYMBOL("av-symbol", EmojiGroup.SYMBOLS),
AWARD_MEDAL("award-medal", EmojiGroup.ACTIVITIES),
BODY_PARTS("body-parts", EmojiGroup.PEOPLE_AND_BODY),
BOOK_PAPER("book-paper", EmojiGroup.OBJECTS),
CAT_FACE("cat-face", EmojiGroup.SMILEYS_AND_EMOTION),
CLOTHING("clothing", EmojiGroup.OBJECTS),
COMPUTER("computer", EmojiGroup.OBJECTS),
COUNTRY_FLAG("country-flag", EmojiGroup.FLAGS),
CURRENCY("currency", EmojiGroup.SYMBOLS),
DISHWARE("dishware", EmojiGroup.FOOD_AND_DRINK),
DRINK("drink", EmojiGroup.FOOD_AND_DRINK),
EMOTION("emotion", EmojiGroup.SMILEYS_AND_EMOTION),
EVENT("event", EmojiGroup.ACTIVITIES),
FACE_AFFECTION("face-affection", EmojiGroup.SMILEYS_AND_EMOTION),
FACE_CONCERNED("face-concerned", EmojiGroup.SMILEYS_AND_EMOTION),
FACE_COSTUME("face-costume", EmojiGroup.SMILEYS_AND_EMOTION),
FACE_GLASSES("face-glasses", EmojiGroup.SMILEYS_AND_EMOTION),
FACE_HAND("face-hand", EmojiGroup.SMILEYS_AND_EMOTION),
FACE_HAT("face-hat", EmojiGroup.SMILEYS_AND_EMOTION),
FACE_NEGATIVE("face-negative", EmojiGroup.SMILEYS_AND_EMOTION),
FACE_NEUTRAL_SKEPTICAL("face-neutral-skeptical", EmojiGroup.SMILEYS_AND_EMOTION),
FACE_SLEEPY("face-sleepy", EmojiGroup.SMILEYS_AND_EMOTION),
FACE_SMILING("face-smiling", EmojiGroup.SMILEYS_AND_EMOTION),
FACE_TONGUE("face-tongue", EmojiGroup.SMILEYS_AND_EMOTION),
FACE_UNWELL("face-unwell", EmojiGroup.SMILEYS_AND_EMOTION),
FAMILY("family", EmojiGroup.PEOPLE_AND_BODY),
FLAG("flag", EmojiGroup.FLAGS),
FOOD_ASIAN("food-asian", EmojiGroup.FOOD_AND_DRINK),
FOOD_FRUIT("food-fruit", EmojiGroup.FOOD_AND_DRINK),
FOOD_MARINE("food-marine", EmojiGroup.FOOD_AND_DRINK),
FOOD_PREPARED("food-prepared", EmojiGroup.FOOD_AND_DRINK),
FOOD_SWEET("food-sweet", EmojiGroup.FOOD_AND_DRINK),
FOOD_VEGETABLE("food-vegetable", EmojiGroup.FOOD_AND_DRINK),
GAME("game", EmojiGroup.ACTIVITIES),
GENDER("gender", EmojiGroup.SYMBOLS),
GEOMETRIC("geometric", EmojiGroup.SYMBOLS),
HAIR_STYLE("hair-style", EmojiGroup.COMPONENT),
HANDS("hands", EmojiGroup.PEOPLE_AND_BODY),
HAND_FINGERS_CLOSED("hand-fingers-closed", EmojiGroup.PEOPLE_AND_BODY),
HAND_FINGERS_OPEN("hand-fingers-open", EmojiGroup.PEOPLE_AND_BODY),
HAND_FINGERS_PARTIAL("hand-fingers-partial", EmojiGroup.PEOPLE_AND_BODY),
HAND_PROP("hand-prop", EmojiGroup.PEOPLE_AND_BODY),
HAND_SINGLE_FINGER("hand-single-finger", EmojiGroup.PEOPLE_AND_BODY),
HEART("heart", EmojiGroup.SMILEYS_AND_EMOTION),
HOTEL("hotel", EmojiGroup.TRAVEL_AND_PLACES),
HOUSEHOLD("household", EmojiGroup.OBJECTS),
KEYCAP("keycap", EmojiGroup.SYMBOLS),
LIGHT_VIDEO("light & video", EmojiGroup.OBJECTS),
LOCK("lock", EmojiGroup.OBJECTS),
MAIL("mail", EmojiGroup.OBJECTS),
MATH("math", EmojiGroup.SYMBOLS),
MEDICAL("medical", EmojiGroup.OBJECTS),
MONEY("money", EmojiGroup.OBJECTS),
MONKEY_FACE("monkey-face", EmojiGroup.SMILEYS_AND_EMOTION),
MUSIC("music", EmojiGroup.OBJECTS),
MUSICAL_INSTRUMENT("musical-instrument", EmojiGroup.OBJECTS),
OFFICE("office", EmojiGroup.OBJECTS),
OTHER_OBJECT("other-object", EmojiGroup.OBJECTS),
OTHER_SYMBOL("other-symbol", EmojiGroup.SYMBOLS),
PERSON("person", EmojiGroup.PEOPLE_AND_BODY),
PERSON_ACTIVITY("person-activity", EmojiGroup.PEOPLE_AND_BODY),
PERSON_FANTASY("person-fantasy", EmojiGroup.PEOPLE_AND_BODY),
PERSON_GESTURE("person-gesture", EmojiGroup.PEOPLE_AND_BODY),
PERSON_RESTING("person-resting", EmojiGroup.PEOPLE_AND_BODY),
PERSON_ROLE("person-role", EmojiGroup.PEOPLE_AND_BODY),
PERSON_SPORT("person-sport", EmojiGroup.PEOPLE_AND_BODY),
PERSON_SYMBOL("person-symbol", EmojiGroup.PEOPLE_AND_BODY),
PHONE("phone", EmojiGroup.OBJECTS),
PLACE_BUILDING("place-building", EmojiGroup.TRAVEL_AND_PLACES),
PLACE_GEOGRAPHIC("place-geographic", EmojiGroup.TRAVEL_AND_PLACES),
PLACE_MAP("place-map", EmojiGroup.TRAVEL_AND_PLACES),
PLACE_OTHER("place-other", EmojiGroup.TRAVEL_AND_PLACES),
PLACE_RELIGIOUS("place-religious", EmojiGroup.TRAVEL_AND_PLACES),
PLANT_FLOWER("plant-flower", EmojiGroup.ANIMALS_AND_NATURE),
PLANT_OTHER("plant-other", EmojiGroup.ANIMALS_AND_NATURE),
PUNCTUATION("punctuation", EmojiGroup.SYMBOLS),
RELIGION("religion", EmojiGroup.SYMBOLS),
SCIENCE("science", EmojiGroup.OBJECTS),
SKIN_TONE("skin-tone", EmojiGroup.COMPONENT),
SKY_WEATHER("sky & weather", EmojiGroup.TRAVEL_AND_PLACES),
SOUND("sound", EmojiGroup.OBJECTS),
SPORT("sport", EmojiGroup.ACTIVITIES),
SUBDIVISION_FLAG("subdivision-flag", EmojiGroup.FLAGS),
TIME("time", EmojiGroup.TRAVEL_AND_PLACES),
TOOL("tool", EmojiGroup.OBJECTS),
TRANSPORT_AIR("transport-air", EmojiGroup.TRAVEL_AND_PLACES),
TRANSPORT_GROUND("transport-ground", EmojiGroup.TRAVEL_AND_PLACES),
TRANSPORT_SIGN("transport-sign", EmojiGroup.SYMBOLS),
TRANSPORT_WATER("transport-water", EmojiGroup.TRAVEL_AND_PLACES),
WARNING("warning", EmojiGroup.SYMBOLS),
WRITING("writing", EmojiGroup.OBJECTS),
ZODIAC("zodiac", EmojiGroup.SYMBOLS);

private static final List<EmojiSubGroup> EMOJI_SUBGROUPS = Arrays.asList(values());
private final String name;
private final EmojiGroup group;

EmojiSubGroup(final String name) {
EmojiSubGroup(final String name, final EmojiGroup group) {
this.name = name;
this.group = group;
}

/**
Expand Down Expand Up @@ -152,4 +155,8 @@ public static EmojiSubGroup fromString(final String name) {
}
throw new IllegalArgumentException("No EmojiSubGroup found for name: " + name);
}

public EmojiGroup getGroup() {
return group;
}
}

0 comments on commit 376c789

Please sign in to comment.