com.enonic.xp.util.BinaryReferences Maven / Gradle / Ivy
The newest version!
package com.enonic.xp.util;
import java.util.stream.Stream;
import com.google.common.collect.ImmutableSet;
import com.enonic.xp.annotation.PublicApi;
import com.enonic.xp.support.AbstractImmutableEntitySet;
@PublicApi
public class BinaryReferences
extends AbstractImmutableEntitySet
{
private static final BinaryReferences EMPTY = new BinaryReferences( ImmutableSet.of() );
private BinaryReferences( final ImmutableSet set )
{
super( set );
}
public static BinaryReferences empty()
{
return EMPTY;
}
public static BinaryReferences from( final String... binaryReferences )
{
return fromInternal( Stream.of( binaryReferences ).map( BinaryReference::from ).collect( ImmutableSet.toImmutableSet() ) );
}
public static BinaryReferences from( final BinaryReference... binaryReferences )
{
return fromInternal( ImmutableSet.copyOf( binaryReferences ) );
}
public static BinaryReferences from( final Iterable binaryReferences )
{
return fromInternal( ImmutableSet.copyOf( binaryReferences ) );
}
private static BinaryReferences fromInternal( final ImmutableSet set )
{
return set.isEmpty() ? EMPTY : new BinaryReferences( set );
}
}