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

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

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

import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableSet;

import com.enonic.xp.support.AbstractImmutableEntityList;

public class NodeHits
    extends AbstractImmutableEntityList
{

    private NodeHits( final ImmutableList hits )
    {
        super( hits );
    }

    public static NodeHits empty()
    {
        return new NodeHits( ImmutableList.of() );
    }

    public NodeIds getNodeIds()
    {
        return NodeIds.from( this.stream().map( NodeHit::getNodeId ).collect( ImmutableSet.toImmutableSet() ) );
    }

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

    public static class Builder
    {
        private final ImmutableList.Builder nodeHits = ImmutableList.builder();

        public Builder add( final NodeHit nodeHit )
        {
            this.nodeHits.add( nodeHit );
            return this;
        }

        public NodeHits build()
        {
            return new NodeHits( this.nodeHits.build() );
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy