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

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

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

import java.util.Collection;
import java.util.LinkedHashSet;
import java.util.Set;

import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableSet;

import com.enonic.xp.branch.Branch;
import com.enonic.xp.repository.RepositoryId;
import com.enonic.xp.support.AbstractImmutableEntitySet;

@Deprecated
public class PushNodeEntries
    extends AbstractImmutableEntitySet
{
    private final Branch targetBranch;

    private final RepositoryId targetRepo;

    private PushNodeEntries( final Builder builder )
    {
        super( ImmutableSet.copyOf( builder.entries ) );
        targetBranch = builder.targetBranch;
        targetRepo = builder.targetRepo;
    }

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

    @Deprecated
    public NodeIds getNodeIds()
    {
        return NodeIds.from( this.set.stream().map( ( entry ) -> entry.getNodeBranchEntry().getNodeId() ).collect( ImmutableSet.toImmutableSet() ) );
    }

    public Branch getTargetBranch()
    {
        return targetBranch;
    }

    public RepositoryId getTargetRepo()
    {
        return targetRepo;
    }

    public static final class Builder
    {
        private final Set entries = new LinkedHashSet<>();

        private Branch targetBranch;

        private RepositoryId targetRepo;

        private Builder()
        {
        }

        public Builder add( final PushNodeEntry val )
        {
            this.entries.add( val );
            return this;
        }

        public Builder addAll( final Collection values )
        {
            this.entries.addAll( values );
            return this;
        }

        private void validate()
        {
            Preconditions.checkNotNull( this.targetBranch, "target-branch must be set in PushNodeEntries" );
        }

        public PushNodeEntries build()
        {
            this.validate();
            return new PushNodeEntries( this );
        }

        public Builder targetBranch( final Branch val )
        {
            targetBranch = val;
            return this;
        }

        public Builder targetRepo( final RepositoryId val )
        {
            targetRepo = val;
            return this;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy