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

com.jparams.store.memory.MemoryStoreBuilder Maven / Gradle / Ivy

There is a newer version: 3.1.4
Show newest version
package com.jparams.store.memory;

import java.util.Collection;

import com.jparams.store.index.IndexDefinition;
import com.jparams.store.index.KeyMapper;

/**
 * Builder for a memory store
 *
 * @param  value type
 */
public final class MemoryStoreBuilder
{
    private final MemoryStore store;

    MemoryStoreBuilder()
    {
        store = new MemoryStore<>();
    }

    public final MemoryStoreBuilder withValue(final V value)
    {
        store.add(value);
        return this;
    }

    public final MemoryStoreBuilder withValues(final Collection values)
    {
        store.addAll(values);
        return this;
    }

    @SafeVarargs
    public final MemoryStoreBuilder withValues(final V... values)
    {
        store.addAll(values);
        return this;
    }

    public final  MemoryStoreBuilder withIndex(final String indexName, final KeyMapper keyMapper)
    {
        store.index(indexName, keyMapper);
        return this;
    }

    public final  MemoryStoreBuilder withIndex(final String indexName, final IndexDefinition indexDefinition)
    {
        store.index(indexName, indexDefinition);
        return this;
    }

    public final MemoryStore build()
    {
        return store;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy