com.ziqni.admin.sdk.streaming.handlers.CallbackConsumer Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ziqni-admin-sdk Show documentation
Show all versions of ziqni-admin-sdk Show documentation
ZIQNI Admin SDK Java Client
package com.ziqni.admin.sdk.streaming.handlers;
import com.fasterxml.jackson.databind.JavaType;
import com.ziqni.admin.sdk.ApiException;
import com.ziqni.admin.sdk.streaming.ApiCallbackResponse;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.springframework.messaging.simp.stomp.StompHeaders;
import java.util.concurrent.CompletableFuture;
import java.util.function.BiConsumer;
public class CallbackConsumer {
private boolean completed = false;
public final JavaType javaType;
private final String callback;
private final Class tClass;
private final BiConsumer onCallback;
private final BiConsumer onApiException;
public CallbackConsumer(Class tClass, String callback, BiConsumer onCallback, BiConsumer onApiException) {
this.tClass = tClass;
this.javaType = CallbackEventHandler.objectMapper.constructType(tClass);
this.callback = callback;
this.onCallback = onCallback;
this.onApiException = onApiException;
}
public JavaType getJavaType() {
return javaType;
}
public String getCallback() {
return callback;
}
public Class gettClass() {
return tClass;
}
public void consumeCallback(StompHeaders headers, Object response) {
onCallback.accept(headers, (T) response);
}
public void consumeApiExceptionCallBack(StompHeaders headers, ApiException response) {
onApiException.accept(headers, response);
}
public boolean isCompleted() {
return completed;
}
public boolean isCompleted(boolean in) {
completed = in;
return completed;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy