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

com.enonic.xp.content.GetActiveContentVersionsResult Maven / Gradle / Ivy

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

import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;

import com.google.common.collect.ImmutableList;

import com.enonic.xp.annotation.PublicApi;

@PublicApi
public class GetActiveContentVersionsResult
{
    private final ImmutableList activeContentVersions;

    private GetActiveContentVersionsResult( final Builder builder )
    {
        this.activeContentVersions = ImmutableList.sortedCopyOf( Comparator.
                                                                     comparing( ActiveContentVersionEntry::getContentVersion, ContentVersionDateComparator.INSTANCE ).
                                                                     thenComparing( ( ActiveContentVersionEntry activeContentVersionEntry ) -> activeContentVersionEntry.getBranch().getValue() ),
                                                                 builder.activeContentVersions );
    }

    public ImmutableList getActiveContentVersions()
    {
        return activeContentVersions;
    }

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

    public static final class Builder
    {
        private final List activeContentVersions = new ArrayList<>();

        private Builder()
        {
        }

        public Builder add( final ActiveContentVersionEntry activeContentVersion )
        {
            if ( activeContentVersion != null && activeContentVersion.getContentVersion() != null )
            {
                this.activeContentVersions.add( activeContentVersion );
            }

            return this;
        }

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




© 2015 - 2024 Weber Informatics LLC | Privacy Policy