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

com.taosdata.jdbc.ws.tmq.ConsumerAction Maven / Gradle / Ivy

There is a newer version: 3.4.0
Show newest version
package com.taosdata.jdbc.ws.tmq;

import com.taosdata.jdbc.ws.entity.Response;
import com.taosdata.jdbc.ws.tmq.entity.*;

import java.util.HashMap;
import java.util.Map;

public enum ConsumerAction {
    // subscribe
    SUBSCRIBE("subscribe", SubscribeResp.class),
    POLL("poll", PollResp.class),
    FETCH("fetch", FetchResp.class),
    FETCH_BLOCK("fetch_block", FetchBlockResp.class),
    COMMIT("commit", CommitResp.class),
    ASSIGNMENT("assignment", AssignmentResp.class),
    SEEK("seek", SeekResp.class),
    UNSUBSCRIBE("unsubscribe", UnsubscribeResp.class)
    ;

    private final String action;
    private final Class clazz;

    ConsumerAction(String action, Class clazz) {
        this.action = action;
        this.clazz = clazz;
    }

    public String getAction() {
        return action;
    }

    public Class getResponseClazz() {
        return clazz;
    }

    private static final Map actions = new HashMap<>();

    static {
        for (ConsumerAction value : ConsumerAction.values()) {
            actions.put(value.action, value);
        }
    }

    public static ConsumerAction of(String action) {
        if (null == action || action.equals("")) {
            return null;
        }
        return actions.get(action);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy