All Downloads are FREE. Search and download functionalities are using the official Maven repository.

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);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy