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

com.enonic.xp.node.SearchTargets Maven / Gradle / Ivy

The newest version!
package com.enonic.xp.node;

import java.util.Collection;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class SearchTargets
    implements Iterable
{
    private final Collection targets;

    private SearchTargets( final Collection targets )
    {
        this.targets = targets;
    }

    private SearchTargets( final Builder builder )
    {
        targets = builder.targets;
    }

    public static Builder create()
    {
        return new Builder();
    }

    public static SearchTargets from( final Collection searchTargets )
    {
        return new SearchTargets( searchTargets );
    }

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

    public static final class Builder
    {
        private final Set targets = new HashSet<>();

        private Builder()
        {
        }

        public Builder add( final SearchTarget target )
        {
            this.targets.add( target );
            return this;
        }

        public SearchTargets build()
        {
            return new SearchTargets( this );
        }
    }
}






© 2015 - 2024 Weber Informatics LLC | Privacy Policy