From 97f993fad0dea34b25cb5da932920971627fd972 Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Fri, 23 Dec 2016 11:09:03 +0300 Subject: juick-protocol: using MethodUtils --- .../src/main/java/com/juick/server/protocol/JuickProtocol.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'juick-server/src/main/java/com') diff --git a/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java b/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java index cd7a4bc1..be68fe62 100644 --- a/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java +++ b/juick-server/src/main/java/com/juick/server/protocol/JuickProtocol.java @@ -10,6 +10,7 @@ import com.juick.service.*; import com.juick.util.TagUtils; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.math.NumberUtils; +import org.apache.commons.lang3.reflect.MethodUtils; import javax.inject.Inject; import java.lang.reflect.InvocationTargetException; @@ -61,8 +62,7 @@ public class JuickProtocol { */ public ProtocolReply getReply(User user, String userInput) throws InvocationTargetException, IllegalAccessException, NoSuchMethodException { - Optional cmd = Arrays.stream(getClass().getDeclaredMethods()) - .filter(m -> m.isAnnotationPresent(UserCommand.class)) + Optional cmd = MethodUtils.getMethodsListWithAnnotation(getClass(), UserCommand.class).stream() .filter(m -> Pattern.compile(m.getAnnotation(UserCommand.class).pattern(), m.getAnnotation(UserCommand.class).patternFlags()).matcher(userInput).matches()) .findFirst(); -- cgit v1.2.3