Java 类com.google.common.collect.MapConstraints 实例源码

项目:benayn    文件:Mapper.java   
/**
 * Add a constraint that verifies that neither the key nor the value is
 * null. If either is null, a {@link NullPointerException} is thrown.
     * 
 * @return
 */
@SuppressWarnings("unchecked")
public Mapper<K, V> keyAndValueNotNull() {
    return addConstraint((MapConstraint<K, V>) MapConstraints.notNull());
}
项目:benayn    文件:Mapper.java   
/**
 * Add a constrained view of the delegate map, using the specified constraint
 * 
 * @param constraint
 * @return
 */
private Mapper<K, V> addConstraint(MapConstraint<K, V> constraint) {
    this.delegate = Optional.of(MapConstraints.constrainedMap(delegate.get(), constraint));
    return this;
}