org.khasanof.executors.matcher.SimpleCallbackMatcher Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of spring-boot-starter-fluent Show documentation
Show all versions of spring-boot-starter-fluent Show documentation
Fluent - Easy Telegram Bots with Spring
package org.khasanof.executors.matcher;
import org.khasanof.annotation.methods.HandleCallback;
import org.khasanof.config.ApplicationConstants;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.Map;
/**
* Author: Nurislom
*
* Date: 20.06.2023
*
* Time: 21:55
*
* Package: org.khasanof.core.executors.matcher
*/
@Component
public class SimpleCallbackMatcher extends GenericMatcher {
public SimpleCallbackMatcher() {
super(ApplicationConstants.MATCHER_MAP);
}
@Override
public boolean matcher(HandleCallback handleCallback, String value) {
return Arrays.stream(handleCallback.values())
.anyMatch(any -> matchFunctions.get(Map.entry(handleCallback.scope(),
getScopeType(value, handleCallback.scope()))).apply(any, value));
}
@Override
public Class getType() {
return HandleCallback.class;
}
}