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

com.jparams.store.index.Index Maven / Gradle / Ivy

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

import java.util.List;
import java.util.Optional;

/**
 * Index applied to a {@link com.jparams.store.Store}
 *
 * @param  value type
 */
public interface Index
{
    /**
     * Get first indexed item matching key. This is the same as {@link Index#findFirst(Object)}, but returns an null instead of an optional if no result found.
     *
     * @param key indexed key to lookup
     * @return optional
     */
    default V getFirst(final Object key)
    {
        return findFirst(key).orElse(null);
    }

    /**
     * Find first indexed item matching key. This is the same as {@link Index#getFirst(Object)}, but returns an optional instead of a null if no result found.
     *
     * @param key indexed key to lookup
     * @return optional
     */
    Optional findFirst(final Object key);

    /**
     * Find all indexed items matching key
     *
     * @param key indexed key to lookup
     * @return matching items
     */
    List get(final Object key);

    /**
     * Get name of index
     *
     * @return index names
     */
    String getName();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy