com.github.twitch4j.eventsub.util.EventSubConditionConverter Maven / Gradle / Ivy
The newest version!
package com.github.twitch4j.eventsub.util;
import com.github.twitch4j.common.util.TypeConvert;
import com.github.twitch4j.eventsub.condition.EventSubCondition;
import com.github.twitch4j.eventsub.subscriptions.SubscriptionType;
import com.github.twitch4j.eventsub.subscriptions.SubscriptionTypes;
import lombok.experimental.UtilityClass;
import java.util.Map;
@UtilityClass
public class EventSubConditionConverter {
public T getCondition(Class conditionClass, Map condition) {
return conditionClass != null ? TypeConvert.convertValue(condition, conditionClass) : null;
}
public EventSubCondition getCondition(String type, String version, Map condition) {
return getCondition(SubscriptionTypes.getSubscriptionType(type, version), condition);
}
public EventSubCondition getCondition(SubscriptionType, ?, ?> type, Map condition) {
return getCondition(type != null ? type.getConditionClass() : null, condition);
}
}