com.softicar.platform.common.container.map.set.ISetMap Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of platform-common Show documentation
Show all versions of platform-common Show documentation
The SoftiCAR Platform is a lightweight, Java-based library to create interactive business web applications.
package com.softicar.platform.common.container.map.set;
import java.util.Collection;
import java.util.Set;
/**
* Map from a key to a set of values.
*
* The goal of this class is to simplify common use cases of a map of sets.
*
* For example, instead of this code:
*
*
* {@code
* Map> setMap = ...;
*
* // insertion
* Set set = setMap.get("foo");
* if (set == null)
* setMap.put("foo", set = new HashSet());
* set.add(42);
*
* // contains
* Set set = setMap.get("foo");
* boolean contains = set != null && set.contains(42);
* }
*
*
* You can write this code:
*
*
* {@code
* ISetMap setMap = ...;
*
* // insertion
* setMap.add("foo", 42);
*
* // contains
* boolean contains = setMap.contains("foo", 42);
* }
*
*
* @param
* the type of the keys
* @param
* the type of the values
* @author Oliver Richers
*/
public interface ISetMap {
void addAllToSet(K key, Collection values);
/**
* Adds the specified value to the set of the specified key.
*
* @param key
* the key of the set
* @param value
* the value to add
* @return true if the set did not already contain the specified
* value, false otherwise
*/
boolean addToSet(K key, V value);
void clear();
/**
* Returns true if a set with the specified key exists and contains
* the given value.
*
* @param key
* the key of the set
* @param value
* the potential value of the set to search for
* @return true if and only if the value exists in the set,
* false otherwise
*/
boolean contains(K key, V value);
boolean containsKey(K key);
Set getSet(K key);
Collection> getSets();
boolean isEmpty();
Set keySet();
void remove(K key);
boolean remove(K key, V value);
int size();
}