Example usage for org.apache.commons.functor.core.composite Not Not

List of usage examples for org.apache.commons.functor.core.composite Not Not

Introduction

In this page you can find the example usage for org.apache.commons.functor.core.composite Not Not.

Prototype

public Not(Predicate predicate) 

Source Link

Document

Create a new Not.

Usage

From source file:org.apache.commons.functor.example.map.FixedSizeMap.java

public FixedSizeMap(Map<K, V> map) {
    super(map);//from  www .  java2s.co  m
    setOnPut(new BinaryFunction<Map<K, V>, Object[], V>() {
        public V evaluate(Map<K, V> map, Object[] b) {
            K key = (K) Array.get(b, 0);
            V value = (V) Array.get(b, 1);
            if (map.containsKey(key)) {
                return map.put(key, value);
            } else {
                throw new IllegalArgumentException();
            }
        }
    });

    setOnPutAll(new BinaryProcedure<Map<K, V>, Map<K, V>>() {
        public void run(Map<K, V> a, Map<K, V> b) {
            Map<K, V> dest = a;
            Map<K, V> src = b;

            if (GeneratorContains.instance().test(IteratorToGeneratorAdapter.adapt(src.keySet().iterator()),
                    Not.not(new ContainsKey(dest)))) {
                throw new IllegalArgumentException();
            } else {
                dest.putAll(src);
            }
        }
    });

    setOnRemove(new BinaryProcedureBinaryFunction<Map<K, V>, K, V>(
            (BinaryProcedure<? super Map<K, V>, ? super K>) new Throw<K, V>(
                    new UnsupportedOperationException())));
    setOnClear(new Throw<K, V>(new UnsupportedOperationException()));
}