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

com.enonic.xp.cluster.Clusters Maven / Gradle / Ivy

There is a newer version: 7.14.4
Show newest version
package com.enonic.xp.cluster;

import java.util.Iterator;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.stream.Collectors;

public class Clusters
    implements Iterable
{
    private final CopyOnWriteArrayList clusters = new CopyOnWriteArrayList<>();

    private final List requiredClusters;

    public Clusters( final List requiredClusters )
    {
        this.requiredClusters = requiredClusters;
    }

    public boolean hasRequiredProviders()
    {
        return this.clusters.stream().map( Cluster::getId ).collect( Collectors.toList() ).containsAll( requiredClusters );
    }

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

    public void add( final Cluster cluster )
    {
        this.clusters.add( cluster );
    }

    public boolean remove( final Cluster cluster )
    {
        return this.clusters.remove( cluster );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy