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

com.enonic.xp.resource.ResourceKeys Maven / Gradle / Ivy

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

import java.util.Arrays;
import java.util.Iterator;

import com.google.common.collect.ImmutableList;

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

@PublicApi
public final class ResourceKeys
    extends AbstractImmutableEntityList
{
    private ResourceKeys( final ImmutableList list )
    {
        super( list );
    }

    public static ResourceKeys from( final ResourceKey... resourceKeys )
    {
        return new ResourceKeys( ImmutableList.copyOf( resourceKeys ) );
    }

    public static ResourceKeys from( final Iterable resourceKeys )
    {
        return new ResourceKeys( ImmutableList.copyOf( resourceKeys ) );
    }

    public static ResourceKeys from( final Iterator resourceKeys )
    {
        return new ResourceKeys( ImmutableList.copyOf( resourceKeys ) );
    }

    public static ResourceKeys from( final String... resourceKeys )
    {
        return new ResourceKeys( parseResourceKeys( resourceKeys ) );
    }

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

    private static ImmutableList parseResourceKeys( final String... resourceKeys )
    {
        return Arrays.stream( resourceKeys ).map( ResourceKey::from ).collect( ImmutableList.toImmutableList() );
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy