com.enonic.xp.node.ReorderChildNodesParams Maven / Gradle / Ivy
package com.enonic.xp.node;
import com.google.common.base.Preconditions;
import com.google.common.collect.ImmutableList;
import com.enonic.xp.annotation.PublicApi;
import com.enonic.xp.support.AbstractImmutableEntityList;
@PublicApi
public class ReorderChildNodesParams
extends AbstractImmutableEntityList
{
private final NodeDataProcessor processor;
private final RefreshMode refresh;
private ReorderChildNodesParams( final Builder builder )
{
super( builder.orderChildNodeParamsList.build() );
this.processor = builder.processor;
this.refresh = builder.refresh;
}
public NodeDataProcessor getProcessor()
{
return processor;
}
public RefreshMode getRefresh()
{
return refresh;
}
public static Builder create()
{
return new Builder();
}
public static class Builder
{
private final ImmutableList.Builder orderChildNodeParamsList = ImmutableList.builder();
private NodeDataProcessor processor = ( n ) -> n;
private RefreshMode refresh;
public Builder add( final ReorderChildNodeParams reorderChildNodeParams )
{
this.orderChildNodeParamsList.add( reorderChildNodeParams );
return this;
}
public Builder processor( final NodeDataProcessor processor )
{
this.processor = processor;
return this;
}
public Builder refresh( final RefreshMode refresh )
{
this.refresh = refresh;
return this;
}
private void validate()
{
Preconditions.checkNotNull( this.processor, "processor must be set" );
}
public ReorderChildNodesParams build()
{
validate();
return new ReorderChildNodesParams( this );
}
}
}