This commit is contained in:
Tracy Boehrer 2019-09-12 15:56:19 -05:00
Родитель a52b018221
Коммит b8442990a8
7 изменённых файлов: 447 добавлений и 134 удалений

Просмотреть файл

@ -4,6 +4,7 @@
package com.microsoft.bot.builder;
import com.microsoft.bot.schema.Activity;
import com.microsoft.bot.schema.ActivityTypes;
import com.microsoft.bot.schema.ChannelAccount;
import com.microsoft.bot.schema.MessageReaction;
import org.apache.commons.lang3.StringUtils;
@ -41,17 +42,17 @@ public class ActivityHandler implements Bot {
}
switch (turnContext.getActivity().getType()) {
case MESSAGE:
case ActivityTypes.MESSAGE:
return onMessageActivity(turnContext);
case CONVERSATION_UPDATE:
case ActivityTypes.CONVERSATION_UPDATE:
return onConversationUpdateActivity(turnContext);
case MESSAGE_REACTION:
case ActivityTypes.MESSAGE_REACTION:
return onMessageReactionActivity(turnContext);
case EVENT:
case ActivityTypes.EVENT:
return onEventActivity(turnContext);
default:
return onUnrecognizedActivity(turnContext);
return onUnrecognizedActivityType(turnContext);
}
}
@ -65,7 +66,7 @@ public class ActivityHandler implements Bot {
* @param turnContext The context object for this turn.
* @return A task that represents the work queued to execute.
*/
public CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
return CompletableFuture.completedFuture(null);
}
@ -84,18 +85,20 @@ public class ActivityHandler implements Bot {
* @param turnContext The context object for this turn.
* @return A task that represents the work queued to execute.
*/
public CompletableFuture<Void> onConversationUpdateActivity(TurnContext turnContext) {
if (turnContext.getActivity().getMembersAdded() != null) {
if (turnContext.getActivity().getMembersAdded().stream()
.anyMatch(m -> StringUtils.equals(m.getId(), turnContext.getActivity().getId()))) {
protected CompletableFuture<Void> onConversationUpdateActivity(TurnContext turnContext) {
Activity activity = turnContext.getActivity();
return onMembersAdded(turnContext.getActivity().getMembersAdded(), turnContext);
if (activity.getMembersAdded() != null) {
if (activity.getRecipient() != null && activity.getMembersAdded().stream()
.anyMatch(m -> !StringUtils.equals(m.getId(), activity.getRecipient().getId()))) {
return onMembersAdded(activity.getMembersAdded(), turnContext);
}
} else if (turnContext.getActivity().getMembersRemoved() != null) {
if (turnContext.getActivity().getMembersRemoved().stream()
.anyMatch(m -> StringUtils.equals(m.getId(), turnContext.getActivity().getId()))) {
} else if (activity.getRecipient() != null && activity.getMembersRemoved() != null) {
if (activity.getMembersRemoved().stream()
.anyMatch(m -> !StringUtils.equals(m.getId(), activity.getRecipient().getId()))) {
return onMembersRemoved(turnContext.getActivity().getMembersRemoved(), turnContext);
return onMembersRemoved(activity.getMembersRemoved(), turnContext);
}
}
@ -149,7 +152,7 @@ public class ActivityHandler implements Bot {
* @param turnContext The context object for this turn.
* @return A task that represents the work queued to execute.
*/
public CompletableFuture onMessageReactionActivity(TurnContext turnContext) {
protected CompletableFuture<Void> onMessageReactionActivity(TurnContext turnContext) {
CompletableFuture task = null;
if (turnContext.getActivity().getReactionsAdded() != null) {
@ -175,7 +178,7 @@ public class ActivityHandler implements Bot {
* @param turnContext The context object for this turn.
* @return A task that represents the work queued to execute.
*/
protected CompletableFuture onReactionsAdded(List<MessageReaction> messageReactions,
protected CompletableFuture<Void> onReactionsAdded(List<MessageReaction> messageReactions,
TurnContext turnContext) {
return CompletableFuture.completedFuture(null);
}
@ -187,7 +190,7 @@ public class ActivityHandler implements Bot {
* @param turnContext The context object for this turn.
* @return A task that represents the work queued to execute.
*/
protected CompletableFuture onReactionsRemoved(List<MessageReaction> messageReactions,
protected CompletableFuture<Void> onReactionsRemoved(List<MessageReaction> messageReactions,
TurnContext turnContext) {
return CompletableFuture.completedFuture(null);
}
@ -205,7 +208,7 @@ public class ActivityHandler implements Bot {
* @param turnContext The context object for this turn.
* @return A task that represents the work queued to execute.
*/
protected CompletableFuture onEventActivity(TurnContext turnContext) {
protected CompletableFuture<Void> onEventActivity(TurnContext turnContext) {
if (StringUtils.equals(turnContext.getActivity().getName(), "tokens/response")) {
return onTokenResponseEvent(turnContext);
}
@ -224,12 +227,12 @@ public class ActivityHandler implements Bot {
* @param turnContext
* @return
*/
protected CompletableFuture onTokenResponseEvent(TurnContext turnContext) {
protected CompletableFuture<Void> onTokenResponseEvent(TurnContext turnContext) {
return CompletableFuture.completedFuture(null);
}
/**
* Invoked when an event other than <c>tokens/response</c> is received when the base behavior of
* Invoked when an event other than tokens/response is received when the base behavior of
* {@link #onEventActivity(TurnContext)} is used.
* <p>
* This method could optionally be overridden if the bot is meant to handle miscellaneous events.
@ -239,7 +242,7 @@ public class ActivityHandler implements Bot {
* @param turnContext The context object for this turn.
* @return A task that represents the work queued to execute.
*/
protected CompletableFuture onEvent(TurnContext turnContext) {
protected CompletableFuture<Void> onEvent(TurnContext turnContext) {
return CompletableFuture.completedFuture(null);
}
@ -256,7 +259,7 @@ public class ActivityHandler implements Bot {
* @param turnContext The context object for this turn.
* @return A task that represents the work queued to execute.
*/
protected CompletableFuture onUnrecognizedActivity(TurnContext turnContext) {
protected CompletableFuture<Void> onUnrecognizedActivityType(TurnContext turnContext) {
return CompletableFuture.completedFuture(null);
}
}

Просмотреть файл

@ -48,7 +48,7 @@ public final class MessageFactory {
* @return A message activity containing the text.
*/
public static Activity text(String text) {
return text(text);
return text(text, null, null);
}
/**

Просмотреть файл

@ -0,0 +1,375 @@
package com.microsoft.bot.builder;
import com.microsoft.bot.schema.*;
import org.junit.Assert;
import org.junit.Test;
import sun.reflect.generics.reflectiveObjects.NotImplementedException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
public class ActivityHandlerTests {
@Test
public void TestMessageActivity() {
Activity activity = MessageFactory.text("hello");
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(1, bot.getRecord().size());
Assert.assertEquals("onMessageActivity", bot.getRecord().get(0));
}
@Test
public void TestMemberAdded1() {
Activity activity = new Activity() {{
setType(ActivityTypes.CONVERSATION_UPDATE);
setMembersAdded(new ArrayList<ChannelAccount>(){{
add(new ChannelAccount("b"));
}});
setRecipient(new ChannelAccount("b"));
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(1, bot.getRecord().size());
Assert.assertEquals("onConversationUpdateActivity", bot.getRecord().get(0));
}
@Test
public void TestMemberAdded2() {
Activity activity = new Activity() {{
setType(ActivityTypes.CONVERSATION_UPDATE);
setMembersAdded(new ArrayList<ChannelAccount>(){{
add(new ChannelAccount("a"));
add(new ChannelAccount("b"));
}});
setRecipient(new ChannelAccount("b"));
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(2, bot.getRecord().size());
Assert.assertEquals("onConversationUpdateActivity", bot.getRecord().get(0));
Assert.assertEquals("onMembersAdded", bot.getRecord().get(1));
}
@Test
public void TestMemberAdded3() {
Activity activity = new Activity() {{
setType(ActivityTypes.CONVERSATION_UPDATE);
setMembersAdded(new ArrayList<ChannelAccount>(){{
add(new ChannelAccount("a"));
add(new ChannelAccount("b"));
add(new ChannelAccount("c"));
}});
setRecipient(new ChannelAccount("b"));
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(2, bot.getRecord().size());
Assert.assertEquals("onConversationUpdateActivity", bot.getRecord().get(0));
Assert.assertEquals("onMembersAdded", bot.getRecord().get(1));
}
@Test
public void TestMemberRemoved1() {
Activity activity = new Activity() {{
setType(ActivityTypes.CONVERSATION_UPDATE);
setMembersRemoved(new ArrayList<ChannelAccount>(){{
add(new ChannelAccount("c"));
}});
setRecipient(new ChannelAccount("c"));
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(1, bot.getRecord().size());
Assert.assertEquals("onConversationUpdateActivity", bot.getRecord().get(0));
}
@Test
public void TestMemberRemoved2() {
Activity activity = new Activity() {{
setType(ActivityTypes.CONVERSATION_UPDATE);
setMembersRemoved(new ArrayList<ChannelAccount>(){{
add(new ChannelAccount("a"));
add(new ChannelAccount("c"));
}});
setRecipient(new ChannelAccount("c"));
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(2, bot.getRecord().size());
Assert.assertEquals("onConversationUpdateActivity", bot.getRecord().get(0));
Assert.assertEquals("onMembersRemoved", bot.getRecord().get(1));
}
@Test
public void TestMemberRemoved3() {
Activity activity = new Activity() {{
setType(ActivityTypes.CONVERSATION_UPDATE);
setMembersRemoved(new ArrayList<ChannelAccount>(){{
add(new ChannelAccount("a"));
add(new ChannelAccount("b"));
add(new ChannelAccount("c"));
}});
setRecipient(new ChannelAccount("c"));
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(2, bot.getRecord().size());
Assert.assertEquals("onConversationUpdateActivity", bot.getRecord().get(0));
Assert.assertEquals("onMembersRemoved", bot.getRecord().get(1));
}
@Test
public void TestMemberAddedJustTheBot() {
Activity activity = new Activity() {{
setType(ActivityTypes.CONVERSATION_UPDATE);
setMembersAdded(new ArrayList<ChannelAccount>(){{
add(new ChannelAccount("b"));
}});
setRecipient(new ChannelAccount("b"));
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(1, bot.getRecord().size());
Assert.assertEquals("onConversationUpdateActivity", bot.getRecord().get(0));
}
@Test
public void TestMemberRemovedJustTheBot() {
Activity activity = new Activity() {{
setType(ActivityTypes.CONVERSATION_UPDATE);
setMembersRemoved(new ArrayList<ChannelAccount>(){{
add(new ChannelAccount("c"));
}});
setRecipient(new ChannelAccount("c"));
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(1, bot.getRecord().size());
Assert.assertEquals("onConversationUpdateActivity", bot.getRecord().get(0));
}
@Test
public void TestMessageReaction() {
// Note the code supports multiple adds and removes in the same activity though
// a channel may decide to send separate activities for each. For example, Teams
// sends separate activities each with a single add and a single remove.
// Arrange
Activity activity = new Activity() {{
setType(ActivityTypes.MESSAGE_REACTION);
setReactionsAdded(new ArrayList<MessageReaction>() {{
add(new MessageReaction("sad"));
}});
setReactionsRemoved(new ArrayList<MessageReaction>() {{
add(new MessageReaction("angry"));
}});
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(3, bot.getRecord().size());
Assert.assertEquals("onMessageReactionActivity", bot.getRecord().get(0));
Assert.assertEquals("onReactionsAdded", bot.getRecord().get(1));
Assert.assertEquals("onReactionsRemoved", bot.getRecord().get(2));
}
@Test
public void TestTokenResponseEventAsync() {
Activity activity = new Activity() {{
setType(ActivityTypes.EVENT);
setName("tokens/response");
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(2, bot.getRecord().size());
Assert.assertEquals("onEventActivity", bot.getRecord().get(0));
Assert.assertEquals("onTokenResponseEvent", bot.getRecord().get(1));
}
@Test
public void TestEventAsync() {
Activity activity = new Activity() {{
setType(ActivityTypes.EVENT);
setName("some.random.event");
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(2, bot.getRecord().size());
Assert.assertEquals("onEventActivity", bot.getRecord().get(0));
Assert.assertEquals("onEvent", bot.getRecord().get(1));
}
@Test
public void TestEventNullNameAsync() {
Activity activity = new Activity() {{
setType(ActivityTypes.EVENT);
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(2, bot.getRecord().size());
Assert.assertEquals("onEventActivity", bot.getRecord().get(0));
Assert.assertEquals("onEvent", bot.getRecord().get(1));
}
@Test
public void TestUnrecognizedActivityType() {
Activity activity = new Activity() {{
setType("shall.not.pass");
}};
TurnContext turnContext = new TurnContextImpl(new NotImplementedAdapter(), activity);
TestActivityHandler bot = new TestActivityHandler();
bot.onTurn(turnContext).join();
Assert.assertEquals(1, bot.getRecord().size());
Assert.assertEquals("onUnrecognizedActivityType", bot.getRecord().get(0));
}
private static class NotImplementedAdapter extends BotAdapter {
@Override
public CompletableFuture<ResourceResponse[]> sendActivities(TurnContext context, Activity[] activities) {
throw new NotImplementedException();
}
@Override
public CompletableFuture<ResourceResponse> updateActivity(TurnContext context, Activity activity) {
throw new NotImplementedException();
}
@Override
public CompletableFuture<Void> deleteActivity(TurnContext context, ConversationReference reference) {
throw new NotImplementedException();
}
}
private static class TestActivityHandler extends ActivityHandler {
private List<String> record = new ArrayList<>();
public List<String> getRecord() {
return record;
}
public void setRecord(List<String> record) {
this.record = record;
}
@Override
protected CompletableFuture<Void> onMessageActivity(TurnContext turnContext) {
record.add("onMessageActivity");
return super.onMessageActivity(turnContext);
}
@Override
protected CompletableFuture<Void> onConversationUpdateActivity(TurnContext turnContext) {
record.add("onConversationUpdateActivity");
return super.onConversationUpdateActivity(turnContext);
}
@Override
protected CompletableFuture<Void> onMembersAdded(List<ChannelAccount> membersAdded, TurnContext turnContext) {
record.add("onMembersAdded");
return super.onMembersAdded(membersAdded, turnContext);
}
@Override
protected CompletableFuture<Void> onMembersRemoved(List<ChannelAccount> membersRemoved, TurnContext turnContext) {
record.add("onMembersRemoved");
return super.onMembersRemoved(membersRemoved, turnContext);
}
@Override
protected CompletableFuture onMessageReactionActivity(TurnContext turnContext) {
record.add("onMessageReactionActivity");
return super.onMessageReactionActivity(turnContext);
}
@Override
protected CompletableFuture onReactionsAdded(List<MessageReaction> messageReactions, TurnContext turnContext) {
record.add("onReactionsAdded");
return super.onReactionsAdded(messageReactions, turnContext);
}
@Override
protected CompletableFuture onReactionsRemoved(List<MessageReaction> messageReactions, TurnContext turnContext) {
record.add("onReactionsRemoved");
return super.onReactionsRemoved(messageReactions, turnContext);
}
@Override
protected CompletableFuture onEventActivity(TurnContext turnContext) {
record.add("onEventActivity");
return super.onEventActivity(turnContext);
}
@Override
protected CompletableFuture onTokenResponseEvent(TurnContext turnContext) {
record.add("onTokenResponseEvent");
return super.onTokenResponseEvent(turnContext);
}
@Override
protected CompletableFuture onEvent(TurnContext turnContext) {
record.add("onEvent");
return super.onEvent(turnContext);
}
@Override
protected CompletableFuture onUnrecognizedActivityType(TurnContext turnContext) {
record.add("onUnrecognizedActivityType");
return super.onUnrecognizedActivityType(turnContext);
}
}
}

Просмотреть файл

@ -35,7 +35,7 @@ public class Activity {
* The {@link ActivityTypes} of the activity.
*/
@JsonProperty(value = "type")
private ActivityTypes type;
private String type;
/**
* Contains an ID that uniquely identifies the activity on the channel.
@ -305,7 +305,7 @@ public class Activity {
* Construct an Activity of the specified type.
* @param withType The activity type.
*/
public Activity(ActivityTypes withType) {
public Activity(String withType) {
this();
setType(withType);
}
@ -458,14 +458,14 @@ public class Activity {
/**
* @see #type
*/
public ActivityTypes getType() {
public String getType() {
return this.type;
}
/**
* @see #type
*/
public void setType(ActivityTypes withType) {
public void setType(String withType) {
this.type = withType;
}
@ -1291,7 +1291,7 @@ public class Activity {
* "pseudo-cast" the activity based on its type.
*/
ActivityTypes type = this.getType();
String type = this.getType();
// If there's no type set then we can't tell if it's the type they're looking for
if (type == null) {
@ -1299,20 +1299,20 @@ public class Activity {
}
// Check if the full type value starts with the type they're looking for
boolean result = StringUtils.startsWith(type.toString().toLowerCase(), activityType.toLowerCase());
boolean result = StringUtils.startsWith(type.toLowerCase(), activityType.toLowerCase());
// If the full type value starts with the type they're looking for, then we need to check a little further
// to check if it's definitely the right type
if (result) {
// If the lengths are equal, then it's the exact type they're looking for
result = type.toString().length() == activityType.length();
result = type.length() == activityType.length();
if (!result) {
// Finally, if the type is longer than the type they're looking for then we need to check if there's
// a / separator right after the type they're looking for
result = type.toString().length() > activityType.length()
result = type.length() > activityType.length()
&&
type.toString().indexOf(activityType.length()) == '/';
type.indexOf(activityType.length()) == '/';
}
}

Просмотреть файл

@ -1,5 +1,5 @@
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Copyright = c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for
* license information.
*/
@ -12,116 +12,79 @@ import com.fasterxml.jackson.annotation.JsonValue;
/**
* Defines values for ActivityTypes.
*/
public enum ActivityTypes {
public final class ActivityTypes {
/**
* Enum value message.
*/
MESSAGE("message"),
public static final String MESSAGE = "message";
/**
* Enum value contactRelationUpdate.
*/
CONTACT_RELATION_UPDATE("contactRelationUpdate"),
public static final String CONTACT_RELATION_UPDATE = "contactRelationUpdate";
/**
* Enum value conversationUpdate.
*/
CONVERSATION_UPDATE("conversationUpdate"),
public static final String CONVERSATION_UPDATE = "conversationUpdate";
/**
* Enum value typing.
*/
TYPING("typing"),
public static final String TYPING = "typing";
/**
* Enum value endOfConversation.
*/
END_OF_CONVERSATION("endOfConversation"),
public static final String END_OF_CONVERSATION = "endOfConversation";
/**
* Enum value event.
*/
EVENT("event"),
public static final String EVENT = "event";
/**
* Enum value invoke.
*/
INVOKE("invoke"),
public static final String INVOKE = "invoke";
/**
* Enum value deleteUserData.
*/
DELETE_USER_DATA("deleteUserData"),
public static final String DELETE_USER_DATA = "deleteUserData";
/**
* Enum value messageUpdate.
*/
MESSAGE_UPDATE("messageUpdate"),
public static final String MESSAGE_UPDATE = "messageUpdate";
/**
* Enum value messageDelete.
*/
MESSAGE_DELETE("messageDelete"),
public static final String MESSAGE_DELETE = "messageDelete";
/**
* Enum value installationUpdate.
*/
INSTALLATION_UPDATE("installationUpdate"),
public static final String INSTALLATION_UPDATE = "installationUpdate";
/**
* Enum value messageReaction.
*/
MESSAGE_REACTION("messageReaction"),
public static final String MESSAGE_REACTION = "messageReaction";
/**
* Enum value suggestion.
*/
SUGGESTION("suggestion"),
public static final String SUGGESTION = "suggestion";
/**
* Enum value trace.
*/
TRACE("trace"),
public static final String TRACE = "trace";
/**
* Enum value handoff.
*/
HANDOFF("handoff");
/**
* The actual serialized value for a ActivityTypes instance.
*/
private String value;
/**
* Creates a ActivityTypes enum from a string.
* @param withValue The string value. Should be a valid enum value.
* @throws IllegalArgumentException If the string doesn't match a valid value.
*/
ActivityTypes(String withValue) {
this.value = withValue;
}
/**
* Parses a serialized value to a ActivityTypes instance.
*
* @param value the serialized value to parse.
* @return the parsed ActivityTypes object, or null if unable to parse.
*/
@JsonCreator
public static ActivityTypes fromString(String value) {
ActivityTypes[] items = ActivityTypes.values();
for (ActivityTypes item : items) {
if (item.toString().equalsIgnoreCase(value)) {
return item;
}
}
return null;
}
@JsonValue
@Override
public String toString() {
return this.value;
}
public static final String HANDOFF = "handoff";
}

Просмотреть файл

@ -20,7 +20,7 @@ public class MessageReaction {
* Message reaction type. Possible values include: 'like', 'plusOne'.
*/
@JsonProperty(value = "type")
private MessageReactionTypes type;
private String type;
public static MessageReaction clone(MessageReaction messageReaction) {
if (messageReaction == null) {
@ -42,13 +42,21 @@ public class MessageReaction {
.collect(Collectors.toCollection(ArrayList::new));
}
public MessageReaction() {
}
public MessageReaction(String withType) {
type = withType;
}
/**
* Get the type value.
*
* @return the type value
*/
public MessageReactionTypes getType() {
public String getType() {
return this.type;
}
@ -57,7 +65,7 @@ public class MessageReaction {
*
* @param withType the type value to set
*/
public void setType(MessageReactionTypes withType) {
public void setType(String withType) {
this.type = withType;
}
}

Просмотреть файл

@ -6,57 +6,21 @@
package com.microsoft.bot.schema;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
/**
* Defines values for MessageReactionTypes.
*/
public enum MessageReactionTypes {
public final class MessageReactionTypes {
private MessageReactionTypes() {
}
/**
* Enum value like.
* like.
*/
LIKE("like"),
public static final String LIKE = "like";
/**
* Enum value plusOne.
*/
PLUS_ONE("plusOne");
/**
* The actual serialized value for a MessageReactionTypes instance.
*/
private String value;
/**
* Creates a ActionTypes enum from a string.
* @param withValue The string value. Should be a valid enum value.
* @throws IllegalArgumentException If the string doesn't match a valid value.
*/
MessageReactionTypes(String withValue) {
this.value = withValue;
}
/**
* Parses a serialized value to a MessageReactionTypes instance.
*
* @param value the serialized value to parse.
* @return the parsed MessageReactionTypes object, or null if unable to parse.
*/
@JsonCreator
public static MessageReactionTypes fromString(String value) {
MessageReactionTypes[] items = MessageReactionTypes.values();
for (MessageReactionTypes item : items) {
if (item.toString().equalsIgnoreCase(value)) {
return item;
}
}
return null;
}
@JsonValue
@Override
public String toString() {
return this.value;
}
public static final String PLUS_ONE = "plusOne";
}