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

com.github.phantomthief.pool.impl.KeyAffinityExecutorForStats Maven / Gradle / Ivy

There is a newer version: 0.1.19
Show newest version
package com.github.phantomthief.pool.impl;

import java.util.Iterator;

import javax.annotation.Nonnull;

import com.github.phantomthief.pool.KeyAffinityExecutor;
import com.github.phantomthief.pool.KeyAffinityExecutorStats;
import com.google.common.util.concurrent.ListeningExecutorService;

/**
 * @author w.vela
 * Created on 2018-11-29.
 */
class KeyAffinityExecutorForStats implements KeyAffinityExecutor {

    private final KeyAffinityExecutor delegate;

    private KeyAffinityExecutorForStats(KeyAffinityExecutor delegate) {
        this.delegate = delegate;
    }

    static  KeyAffinityExecutor wrapStats(KeyAffinityExecutor executor) {
        if (executor instanceof KeyAffinityExecutorForStats) {
            return executor;
        } else {
            return new KeyAffinityExecutorForStats<>(executor);
        }
    }

    @Nonnull
    @Override
    public ListeningExecutorService select(K key) {
        throw new UnsupportedOperationException();
    }

    @Override
    public void finishCall(K key) {
        throw new UnsupportedOperationException();
    }

    @Override
    public boolean inited() {
        return delegate.inited();
    }

    @Override
    public void close() {
        throw new UnsupportedOperationException();
    }

    @Override
    public Iterator iterator() {
        return delegate.iterator();
    }

    @Override
    public KeyAffinityExecutorStats stats() {
        if (delegate.inited()) {
            return delegate.stats();
        } else {
            return null;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy