com.ajjpj.abase.collection.immutable.AMapWithDefault Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of a-base Show documentation
Show all versions of a-base Show documentation
a-base is a library of basic (hence the name) classes, most notably immutable collection classes with copy-on-write operations
package com.ajjpj.abase.collection.immutable;
import com.ajjpj.abase.function.AFunction1;
/**
* @author arno
*/
class AMapWithDefault extends AWrappedMap {
private final AFunction1 super K, ? extends V, ? extends RuntimeException> defaultFunction;
AMapWithDefault(AMap inner, AFunction1 super K, ? extends V, ? extends RuntimeException> defaultFunction) {
super(inner);
this.defaultFunction = defaultFunction;
}
@Override AMap wrap(AMap inner) {
return new AMapWithDefault<>(inner, defaultFunction);
}
@Override V defaultValue(K key) {
return defaultFunction.apply(key);
}
}