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

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

There is a newer version: 7.14.4
Show 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 ResolveSyncWorkResult
    implements Iterable
{
    private final NodeComparisons nodeComparisons;

    private ResolveSyncWorkResult( final Builder builder )
    {
        nodeComparisons = builder.comparisonsBuilder.build();
    }

    private ResolveSyncWorkResult( final Set nodeComparisons )
    {
        this.nodeComparisons = NodeComparisons.create().
            addAll( nodeComparisons ).
            build();
    }

    public static ResolveSyncWorkResult empty()
    {
        return new ResolveSyncWorkResult( new HashSet<>() );
    }

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

    public int getSize()
    {
        return this.getNodeComparisons().getSize();
    }

    public NodeComparisons getNodeComparisons()
    {
        return nodeComparisons;
    }

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

    public static final class Builder
    {
        private final NodeComparisons.Builder comparisonsBuilder = NodeComparisons.create();

        private Builder()
        {
        }

        public Builder add( final NodeComparison val )
        {
            this.comparisonsBuilder.add( val );
            return this;
        }

        public Builder addAll( final Collection val )
        {
            this.comparisonsBuilder.addAll( val );
            return this;
        }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy