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

ru.yandex.qatools.camelot.api.ReadonlyStorage Maven / Gradle / Ivy

There is a newer version: 2.5.4
Show newest version
package ru.yandex.qatools.camelot.api;

import java.util.HashMap;
import java.util.Map;
import java.util.Set;

/**
 * Storage that allows only read operations
 *
 * @author Ilya Sadykov (mailto: [email protected])
 * @author Innokenty Shuvalov (mailto: [email protected])
 */
public interface ReadonlyStorage {

    /**
     * Get the value of the key. Returns null if no value is present
     */
    T get(String key);

    /**
     * Get the list of the keys in the storage
     */
    Set keys();

    /**
     * Get only the local keys (on the current node)
     */
    default Set localKeys() {
        return keys();
    }

    /**
     * Returns a map of all keys to the corresponding states
     */
    default Map valuesMap() {
        Set keys = keys();
        Map result = new HashMap<>(keys.size(), 1);
        for (String key : keys) {
            result.put(key, get(key));
        }
        return result;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy