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

lucee.commons.lang.WeakConcurrentHashMapAsHashtable Maven / Gradle / Ivy

There is a newer version: 6.2.0.164-RC
Show newest version
package lucee.commons.lang;

import java.util.Hashtable;

public class WeakConcurrentHashMapAsHashtable extends Hashtable {
	/*
	 * private static final Reference DEFAULT_VALUE = new WeakReference("");
	 * 
	 * private ConcurrentHashMap> map;
	 * 
	 * public WeakConcurrentHashMapAsHashtable() { this.map = new ConcurrentHashMap<>(); }
	 * 
	 * @Override public int size() { int size = 0; for (Reference ref: map.values()) { if (ref !=
	 * null && ref.get() != null) size++; }
	 * 
	 * return size; }
	 * 
	 * @Override public boolean isEmpty() { for (Reference ref: map.values()) { if (ref != null &&
	 * ref.get() != null) return false; } return true; }
	 * 
	 * @Override public Enumeration keys() { return entries().keys(); }
	 * 
	 * @Override public Enumeration elements() { return entries().elements(); }
	 * 
	 * @Override public boolean contains(Object value) { return map.containsValue(value); }
	 * 
	 * @Override public boolean containsValue(Object value) { if (value == null) throw new
	 * NullPointerException();
	 * 
	 * for (Reference ref: map.values()) { if (ref != null && ref.get() != null && (ref.get() ==
	 * value || ref.get().equals(value))) return true; } return false; }
	 * 
	 * @Override public boolean containsKey(Object key) { if (key == null) throw new
	 * NullPointerException(); Reference ref = map.get(key); return ref != null && ref.get() != null;
	 * }
	 * 
	 * @Override public V get(Object key) { Reference ref = map.get(key); return ref != null ?
	 * ref.get() : null; }
	 * 
	 * @Override protected void rehash() { // do nothing }
	 * 
	 * @Override public V put(K key, V value) { Reference ref = map.put(key, new
	 * WeakReference(value)); return ref != null ? ref.get() : null; }
	 * 
	 * private void putIgnoreNull(K key, V value) { if (value != null) map.put(key, new
	 * WeakReference(value)); }
	 * 
	 * @Override public V remove(Object key) { Reference ref = map.remove(key); return ref != null ?
	 * ref.get() : null; }
	 * 
	 * @Override public void putAll(Map m) { for (Map.Entry e: m.entrySet()) { put(e.getKey(), e.getValue()); } }
	 * 
	 * @Override public void clear() { map.clear(); }
	 * 
	 * @Override public Object clone() { ConcurrentHashMapAsHashtable newMap = new
	 * ConcurrentHashMapAsHashtable<>(); Reference ref; for (java.util.Map.Entry> e:
	 * map.entrySet()) { ref = e.getValue(); if (ref != null) newMap.putIgnoreNull(e.getKey(),
	 * ref.get()); } return newMap; }
	 * 
	 * @Override public String toString() {
	 * 
	 * return map.toString(); }
	 * 
	 * @Override public Set keySet() {
	 * 
	 * return map.keySet(); }
	 * 
	 * @Override public Set> entrySet() { return entries().entrySet(); }
	 * 
	 * @Override public Collection values() { return entries().values(); }
	 * 
	 * @Override public boolean equals(Object o) {
	 * 
	 * return map.equals(o); }
	 * 
	 * @Override public int hashCode() {
	 * 
	 * return map.hashCode(); }
	 * 
	 * @Override public V getOrDefault(Object key, V defaultValue) { Reference ref =
	 * map.getOrDefault(key, DEFAULT_VALUE); return ref == DEFAULT_VALUE ? defaultValue : (V) ref.get();
	 * }
	 * 
	 * @Override public void forEach(BiConsumer action) {
	 * entries().forEach(action); }
	 * 
	 * @Override public void replaceAll(BiFunction function) {
	 * 
	 * map.replaceAll(function); }
	 * 
	 * @Override public V putIfAbsent(K key, V value) {
	 * 
	 * return map.putIfAbsent(key, value); }
	 * 
	 * @Override public boolean remove(Object key, Object value) {
	 * 
	 * return map.remove(key, value); }
	 * 
	 * @Override public boolean replace(K key, V oldValue, V newValue) {
	 * 
	 * return map.replace(key, oldValue, newValue); }
	 * 
	 * @Override public V replace(K key, V value) {
	 * 
	 * return map.replace(key, value); }
	 * 
	 * @Override public V computeIfAbsent(K key, Function mappingFunction) {
	 * 
	 * return map.computeIfAbsent(key, mappingFunction); }
	 * 
	 * @Override public V computeIfPresent(K key, BiFunction
	 * remappingFunction) {
	 * 
	 * return map.computeIfPresent(key, remappingFunction); }
	 * 
	 * @Override public V compute(K key, BiFunction
	 * remappingFunction) {
	 * 
	 * return map.compute(key, remappingFunction); }
	 * 
	 * @Override public V merge(K key, V value, BiFunction
	 * remappingFunction) {
	 * 
	 * return map.merge(key, value, remappingFunction); }
	 * 
	 * private ConcurrentHashMap entries() { ConcurrentHashMap entries = new
	 * ConcurrentHashMap<>(); V v; for (Entry> e: map.entrySet()) { if (e.getValue() !=
	 * null) { v = e.getValue().get(); if (v != null) entries.put(e.getKey(), e.getValue().get()); } }
	 * return entries; }
	 */
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy