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

org.fuchss.objectcasket.common.IntolerantMap Maven / Gradle / Ivy

Go to download

Object Casket is a simple O/R mapper that can be used together with the Java Persistence API (JPA). The aim is to provide a simple solution for small projects to store multi-related entities in a simple manner.

There is a newer version: 0.20.17
Show newest version
package org.fuchss.objectcasket.common;

import java.util.Map;

/**
 * A special variant of a {@link Map} which guarantees that an existing key
 * cannot be rewritten and only existing objects can be retrieved.
 *
 * @param  - a type variable for keys.
 * @param  -a type variable for values.
 * @see Map
 */
public interface IntolerantMap extends Map {

	/**
	 * @param key - the key.
	 * @return the stored VALUE to which the key is mapped.
	 * @throws CasketException if no mapping for this key exists or the value is null.
	 * @see Map#get(Object)
	 */

	V getIfExists(Object key) throws CasketException;

	/**
	 * @param key - the key.
	 * @param val - the value.
	 * @throws CasketException if one of the parameters are null or a mapping for this key
	 *                         already exists.
	 * @see Map#put(Object, Object)
	 */
	void putIfNew(K key, V val) throws CasketException;

	/**
	 * This method casts the key to the correct type and checks that the key exists.
	 *
	 * @param key - an existing key.
	 * @return the same object.
	 * @throws CasketException if the key is not mapped to any object.
	 */
	K keyExists(Object key) throws CasketException;

	/**
	 * This method casts the value to the correct type and checks that a mapping for
	 * this value exists.
	 *
	 * @param value - an existing value.
	 * @return the same object.
	 * @throws CasketException if no mapping exists or the value is null.
	 */
	V valueExists(Object value) throws CasketException;

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy