com.jparams.store.memory.MemoryStoreBuilder Maven / Gradle / Ivy
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;
}
}