org.camunda.commons.utils.cache.Cache Maven / Gradle / Ivy
The newest version!
/*
* Copyright Camunda Services GmbH and/or licensed to Camunda Services GmbH
* under one or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information regarding copyright
* ownership. Camunda licenses this file to you under the Apache License,
* Version 2.0; you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.camunda.commons.utils.cache;
import java.util.Set;
/**
* A Map-like data structure that stores key-value pairs and provides temporary
* access to it.
*
* @param the type of keys
* @param the type of mapped values
*/
public interface Cache {
/**
* Gets an entry from the cache.
*
* @param key the key whose associated value is to be returned
* @return the element, or null
, if it does not exist.
*/
V get(K key);
/**
* Associates the specified value with the specified key in the cache.
*
* @param key key with which the specified value is to be associated
* @param value value to be associated with the specified key
* @throws NullPointerException if key is null
or if value is null
*/
void put(K key, V value);
/**
* Clears the contents of the cache.
*/
void clear();
/**
* Removes an entry from the cache.
*
* @param key key with which the specified value is to be associated.
*/
void remove(K key);
/**
* Returns a Set view of the keys contained in this cache.
*/
public Set keySet();
/**
* @return the current size of the cache
*/
public int size();
/**
* Returns true
if this cache contains no key-value mappings.
*/
public boolean isEmpty();
}