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

com.enonic.xp.site.XDataMappings Maven / Gradle / Ivy

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

import java.util.Collection;
import java.util.stream.Collectors;

import com.google.common.collect.ImmutableList;

import com.enonic.xp.annotation.PublicApi;
import com.enonic.xp.schema.xdata.XDataNames;
import com.enonic.xp.support.AbstractImmutableEntityList;

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

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

    public static XDataMappings from( final XDataMapping... xDataMappings )
    {
        return new XDataMappings( ImmutableList.copyOf( xDataMappings ) );
    }

    public static XDataMappings from( final Iterable xDataMappings )
    {
        return new XDataMappings( ImmutableList.copyOf( xDataMappings ) );
    }

    public static XDataMappings from( final Collection xDataMappings )
    {
        return new XDataMappings( ImmutableList.copyOf( xDataMappings ) );
    }

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

    public XDataNames getNames()
    {
        return XDataNames.from( this.stream().map( XDataMapping::getXDataName ).collect( Collectors.toList() ) );
    }

    public static class Builder
    {
        private final ImmutableList.Builder builder = ImmutableList.builder();

        public XDataMappings.Builder add( XDataMapping xDataMapping )
        {
            builder.add( xDataMapping );
            return this;
        }

        public XDataMappings.Builder addAll( XDataMappings xDataMappings )
        {
            builder.addAll( xDataMappings );
            return this;
        }

        public XDataMappings.Builder addAll( Collection xDataMappings )
        {
            builder.addAll( xDataMappings );
            return this;
        }

        public XDataMappings build()
        {
            return new XDataMappings( builder.build() );
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy