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

com.custardsource.parfait.CompositeMonitoringView Maven / Gradle / Ivy

The newest version!
package com.custardsource.parfait;

import com.google.common.base.Predicate;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.Iterators;

import java.util.Collection;
import java.util.List;

import static com.google.common.collect.ImmutableList.copyOf;

public class CompositeMonitoringView implements MonitoringView{

    private final List monitoringViews;

    public CompositeMonitoringView(MonitoringView... monitoringViews) {
        this.monitoringViews = copyOf(monitoringViews);
    }

    @Override
    public void startMonitoring(Collection> monitorables) {
        for (MonitoringView monitoringView : monitoringViews) {
            monitoringView.startMonitoring(monitorables);
        }
    }

    @Override
    public void stopMonitoring(Collection> monitorables) {
        for (MonitoringView monitoringView : monitoringViews) {
            monitoringView.stopMonitoring(monitorables);
        }
    }

    @Override
    /**
     * For a Composite view, isRunning() is true if any of the underlying views are still running
     */
    public boolean isRunning() {
        return Iterators.any(monitoringViews.iterator(), new Predicate() {
            @Override
            public boolean apply(MonitoringView mv) {
                return mv.isRunning();
            }
        });
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy