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

com.github.phantomthief.jedis.OpInterceptor Maven / Gradle / Ivy

There is a newer version: 0.1.15
Show newest version
package com.github.phantomthief.jedis;

import java.io.Closeable;
import java.lang.reflect.Method;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * @author w.vela
 * Created on 2017-08-11.
 */
public interface OpInterceptor {

    /**
     * @return {@code null} if didn't want to change any behavior.
     */
    @Nullable
    JedisOpCall interceptCall(P pool, Method method, J jedis, Object[] args);

    class JedisOpCall {

        private final Method method;
        private final J jedis;
        private final Object[] args;

        private Object finalObject;
        private boolean hasFinalObject;

        public JedisOpCall(@Nonnull Method method, @Nonnull J jedis, @Nonnull Object[] args) {
            this.method = method;
            this.jedis = jedis;
            this.args = args;
        }

        boolean hasFinalObject() {
            return hasFinalObject;
        }

        Object getFinalObject() {
            return finalObject;
        }

        public JedisOpCall setFinalObject(Object obj) {
            this.finalObject = obj;
            hasFinalObject = true;
            return this;
        }

        Method getMethod() {
            return method;
        }

        J getJedis() {
            return jedis;
        }

        Object[] getArgs() {
            return args;
        }
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy