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

io.infinicast.client.impl.query.PathQueryWithHandlerExecutor Maven / Gradle / Ivy

There is a newer version: 3.0.10
Show newest version
package io.infinicast.client.impl.query;

import io.infinicast.JObject;
import io.infinicast.Logger;
import io.infinicast.LoggerFactory;
import io.infinicast.TriConsumer;
import io.infinicast.client.api.IPath;
import io.infinicast.client.api.paths.HandlerRegistrationOptions;
import io.infinicast.client.api.paths.IAPathContext;
import io.infinicast.client.api.paths.IPathAndEndpointContext;
import io.infinicast.client.api.paths.handler.messages.APMessageCallback;
import io.infinicast.client.api.paths.handler.messages.APValidateDataChangeCallback;
import io.infinicast.client.api.paths.handler.messages.APValidateMessageCallback;
import io.infinicast.client.api.paths.handler.objects.APObjectIntroduceCallback;
import io.infinicast.client.api.paths.handler.reminders.AReminderCallback;
import io.infinicast.client.api.paths.handler.requests.APRequestCallback;
import io.infinicast.client.api.paths.options.CompleteCallback;
import io.infinicast.client.api.query.ListenTerminateReason;
import io.infinicast.client.impl.IConnector;
import io.infinicast.client.impl.messaging.ConnectorMessageManager;
import io.infinicast.client.impl.messaging.handlers.DCloudMessageHandler;
import io.infinicast.client.impl.pathAccess.RequestResponder;
import io.infinicast.client.impl.responder.ValidationResponder;
import io.infinicast.client.protocol.Connector2EpsMessageType;

import java.util.function.BiConsumer;
public class PathQueryWithHandlerExecutor extends BaseQueryExecutor  {
    Logger _logger = LoggerFactory.getLogger(PathQueryWithHandlerExecutor.class);
    public PathQueryWithHandlerExecutor(IConnector connector, IPath path, ConnectorMessageManager messageManager) {
        super(connector, path, messageManager);
    }
    public void onDataChange(final TriConsumer callback, HandlerRegistrationOptions options, CompleteCallback completeCallback) {
        PathQueryWithHandlerExecutor self = this;
        super._messageManager.addHandler(false, Connector2EpsMessageType.SetObjectData, super._path, new DCloudMessageHandler() {
            public void accept(JObject json, IPathAndEndpointContext context, int id) {
                JObject newOb = null;
                JObject oldOb = null;
                if (json.containsNonNull("new")) {
                    newOb = json.getJObject("new");
                }
                if (json.containsNonNull("old")) {
                    oldOb = json.getJObject("old");
                }
                callback.accept(newOb, oldOb, context);
                ;
            }
        }
        , completeCallback, options);
    }
    public void onDataChange(final TriConsumer callback, HandlerRegistrationOptions options) {
        this.onDataChange(callback, options, (CompleteCallback) null);
    }
    public void onDataChange(final TriConsumer callback) {
        this.onDataChange(callback, (HandlerRegistrationOptions) null, (CompleteCallback) null);
    }
    public void onValidateDataChange(final APValidateDataChangeCallback callback, HandlerRegistrationOptions options, CompleteCallback completeCallback) {
        PathQueryWithHandlerExecutor self = this;
        super._messageManager.addHandler((callback == null), Connector2EpsMessageType.DataChangeValidate, super._path, new DCloudMessageHandler() {
            public void accept(JObject json, IPathAndEndpointContext context, int id) {
                JObject newOb = null;
                JObject oldOb = null;
                if (json.containsNonNull("new")) {
                    newOb = json.getJObject("new");
                }
                if (json.containsNonNull("old")) {
                    oldOb = json.getJObject("old");
                }
                callback.accept(newOb, oldOb, new ValidationResponder(Connector2EpsMessageType.DataChangeValidated, _messageManager, newOb, context.getPath(), context.getEndpoint()), context);
                ;
            }
        }
        , completeCallback, options);
    }
    public void onValidateDataChange(final APValidateDataChangeCallback callback, HandlerRegistrationOptions options) {
        this.onValidateDataChange(callback, options, (CompleteCallback) null);
    }
    public void onValidateDataChange(final APValidateDataChangeCallback callback) {
        this.onValidateDataChange(callback, (HandlerRegistrationOptions) null, (CompleteCallback) null);
    }
    public void onValidateMessage(final APValidateMessageCallback callback, HandlerRegistrationOptions options, CompleteCallback completeCallback) {
        PathQueryWithHandlerExecutor self = this;
        super._messageManager.addHandler((callback == null), Connector2EpsMessageType.MessageValidate, super._path, new DCloudMessageHandler() {
            public void accept(JObject json, IPathAndEndpointContext context, int id) {
                callback.accept(json, new ValidationResponder(Connector2EpsMessageType.MessageValidated, _messageManager, json, context.getPath(), context.getEndpoint()), context);
                ;
            }
        }
        , completeCallback, options);
    }
    public void onValidateMessage(final APValidateMessageCallback callback, HandlerRegistrationOptions options) {
        this.onValidateMessage(callback, options, (CompleteCallback) null);
    }
    public void onValidateMessage(final APValidateMessageCallback callback) {
        this.onValidateMessage(callback, (HandlerRegistrationOptions) null, (CompleteCallback) null);
    }
    public void onMessage(final APMessageCallback callback, HandlerRegistrationOptions options, CompleteCallback completeCallback, BiConsumer listenTerminationHandler) {
        PathQueryWithHandlerExecutor self = this;
        super._messageManager.addHandler((callback == null), Connector2EpsMessageType.Message, super._path, new DCloudMessageHandler() {
            public void accept(JObject json, IPathAndEndpointContext context, int id) {
                callback.accept(json, context);
                ;
            }
        }
        , completeCallback, options, listenTerminationHandler);
    }
    public void onMessage(final APMessageCallback callback, HandlerRegistrationOptions options, CompleteCallback completeCallback) {
        this.onMessage(callback, options, completeCallback, (BiConsumer) null);
    }
    public void onMessage(final APMessageCallback callback, HandlerRegistrationOptions options) {
        this.onMessage(callback, options, (CompleteCallback) null, (BiConsumer) null);
    }
    public void onMessage(final APMessageCallback callback) {
        this.onMessage(callback, (HandlerRegistrationOptions) null, (CompleteCallback) null, (BiConsumer) null);
    }
    public void onRequest(final APRequestCallback callback, HandlerRegistrationOptions options, CompleteCallback completeCallback) {
        PathQueryWithHandlerExecutor self = this;
        super._messageManager.addHandler((callback == null), Connector2EpsMessageType.Request, super._path, new DCloudMessageHandler() {
            public void accept(JObject json, IPathAndEndpointContext context, int requestId) {
                callback.accept(json, new RequestResponder(_messageManager, context.getPath(), context.getEndpoint().getEndpointId(), requestId), context);
                ;
            }
        }
        , completeCallback, options);
    }
    public void onRequest(final APRequestCallback callback, HandlerRegistrationOptions options) {
        this.onRequest(callback, options, (CompleteCallback) null);
    }
    public void onRequest(final APRequestCallback callback) {
        this.onRequest(callback, (HandlerRegistrationOptions) null, (CompleteCallback) null);
    }
    public void onReminder(final AReminderCallback callback, HandlerRegistrationOptions options, CompleteCallback completeCallback) {
        PathQueryWithHandlerExecutor self = this;
        super._messageManager.addHandler((callback == null), Connector2EpsMessageType.Reminder, super._path, new DCloudMessageHandler() {
            public void accept(JObject json, IPathAndEndpointContext context, int id) {
                callback.accept(json, context);
                ;
            }
        }
        , completeCallback, options);
    }
    public void onReminder(final AReminderCallback callback, HandlerRegistrationOptions options) {
        this.onReminder(callback, options, (CompleteCallback) null);
    }
    public void onReminder(final AReminderCallback callback) {
        this.onReminder(callback, (HandlerRegistrationOptions) null, (CompleteCallback) null);
    }
    public void onIntroduce(final APObjectIntroduceCallback callback, CompleteCallback completeCallback) {
        PathQueryWithHandlerExecutor self = this;
        super._messageManager.addHandler((callback == null), Connector2EpsMessageType.IntroduceObject, super._path, new DCloudMessageHandler() {
            public void accept(JObject json, IPathAndEndpointContext context, int id) {
                callback.accept(json, context);
                ;
            }
        }
        , completeCallback, null);
    }
    public void onIntroduce(final APObjectIntroduceCallback callback) {
        this.onIntroduce(callback, (CompleteCallback) null);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy