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

com.github.napp.util.mass.AIMap Maven / Gradle / Ivy

There is a newer version: 1.1.8
Show newest version
/**
 *
 */
package com.github.napp.util.mass;

import java.util.Collection;
import java.util.Map;
import java.util.Set;

/**
 * Auto Initializing Map
 * @author Alexandru Bledea
 * @since Oct 19, 2013
 */
public final class AIMap implements Map {

	private final Map map;
	private final IEvaluator initializer;

	/**
	 * @param map
	 * @param initializer
	 */
	public AIMap(Map map, IEvaluator initializer) {
		this.map = map;
		this.initializer = initializer;
	}

	/* (non-Javadoc)
	 * @see java.util.Map#size()
	 */
	@Override
	public int size() {
		return map.size();
	}

	/* (non-Javadoc)
	 * @see java.util.Map#isEmpty()
	 */
	@Override
	public boolean isEmpty() {
		return map.isEmpty();
	}

	/* (non-Javadoc)
	 * @see java.util.Map#containsKey(java.lang.Object)
	 */
	@Override
	public boolean containsKey(Object key) {
		return map.containsKey(key);
	}

	/* (non-Javadoc)
	 * @see java.util.Map#containsValue(java.lang.Object)
	 */
	@Override
	public boolean containsValue(Object value) {
		return map.containsKey(value);
	}

	/* (non-Javadoc)
	 * @see java.util.Map#get(java.lang.Object)
	 */
	@SuppressWarnings ("deprecation")
	@Override
	public V get(Object key) {
		return MapUtil.get(map, (K) key, (I) key, initializer);
	}

	/* (non-Javadoc)
	 * @see java.util.Map#put(java.lang.Object, java.lang.Object)
	 */
	@Override
	public V put(K key, V value) {
		return map.put(key, value);
	}

	/* (non-Javadoc)
	 * @see java.util.Map#remove(java.lang.Object)
	 */
	@Override
	public V remove(Object key) {
		return map.remove(key);
	}

	/* (non-Javadoc)
	 * @see java.util.Map#putAll(java.util.Map)
	 */
	@Override
	public void putAll(Map m) {
		map.putAll(m);
	}

	/* (non-Javadoc)
	 * @see java.util.Map#clear()
	 */
	@Override
	public void clear() {
		map.clear();
	}

	/* (non-Javadoc)
	 * @see java.util.Map#keySet()
	 */
	@Override
	public Set keySet() {
		return map.keySet();
	}

	/* (non-Javadoc)
	 * @see java.util.Map#values()
	 */
	@Override
	public Collection values() {
		return map.values();
	}

	/* (non-Javadoc)
	 * @see java.util.Map#entrySet()
	 */
	@Override
	public Set> entrySet() {
		return map.entrySet();
	}

	/* (non-Javadoc)
	 * @see java.lang.Object#toString()
	 */
	@Override
	public String toString() {
		return map.toString();
	}

	/**
	 * Wraps a Map into a {@link AIMap} 
* @param map * @param initializer * @return */ public final static Map wrap(Map map, IEvaluator initializer) { return new AIMap(map, initializer); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy