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

com.enonic.xp.blob.BlobKeys Maven / Gradle / Ivy

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

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

import com.google.common.collect.ImmutableSet;

import com.enonic.xp.annotation.PublicApi;
import com.enonic.xp.support.AbstractImmutableEntitySet;

@PublicApi
public class BlobKeys
    extends AbstractImmutableEntitySet
{
    private BlobKeys( final ImmutableSet set )
    {
        super( set );
    }

    public static BlobKeys empty()
    {
        return new BlobKeys( ImmutableSet.of() );
    }

    public static BlobKeys from( final BlobKey... blobKeys )
    {
        return new BlobKeys( ImmutableSet.copyOf( blobKeys ) );
    }


    public static BlobKeys from( final Collection blobKeys )
    {
        return new BlobKeys( ImmutableSet.copyOf( blobKeys ) );
    }

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

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

        public Builder add( final BlobKey blobKey )
        {
            this.blobKeys.add( blobKey );
            return this;
        }

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


        public BlobKeys build()
        {
            return new BlobKeys( ImmutableSet.copyOf( this.blobKeys ) );
        }

    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy