package me.xdrop.ensurej;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

public class MapHandler<K, V> extends Handler<MapHandler<K, V>> {

    private Map<K, V> map;

    public MapHandler(Map<K, V> map) {
        this.map = map;
    }

    class KeyHandler<T> extends Handler<KeyHandler<T>> {
        private List<Predicate<K>> keyPredicates;

        public KeyHandler(List<Predicate<K>> keyPredicates) {
            this.keyPredicates = keyPredicates;
        }

        public KeyHandler(Predicate<K> keyPredicate) {
            this.keyPredicates = new ArrayList<>();
            keyPredicates.add(keyPredicate);
        }

        public KeyHandler<T> add(Predicate<K> keyPredicate){
            keyPredicates.add(keyPredicate);
            return this;
        }

    }

    class ValueHandler<T> extends Handler<KeyHandler<T>> {
        private List<Predicate<T>> valuePredicates;

        public ValueHandler(List<Predicate<T>> valuePredicates) {
            this.valuePredicates = valuePredicates;
        }

        public ValueHandler(Predicate<T> valuePredicate) {
            this.valuePredicates = new ArrayList<>();
            valuePredicates.add(valuePredicate);
        }

        public ValueHandler<T> add(Predicate<T> valuePredicate){
            valuePredicates.add(valuePredicate);
            return this;
        }

    }

    public KeyHandler<K> keys(Predicate<K> keyCheck) {
        return new KeyHandler<K>(keyCheck);
    }

    public KeyHandler<K> keys(Predicate<K> ... keyChecks) {
        return new KeyHandler<>(Arrays.asList(keyChecks));
    }

    public ValueHandler<V> values(Predicate<V> valueCheck) {
        return new ValueHandler<>(Arrays.asList(valueCheck));
    }

    public ValueHandler<V> values(Predicate<V> ... valueChecks) {
        return new ValueHandler<>(Arrays.asList(valueChecks));
    }

}

@@ -810,32 +810,368 @@
 his;%0A        %7D%0A%0A
+        public Chain%3CVoid, MapHandler%3CK,V%3E%3E all()%7B%0A            return new Chain%3CVoid, MapHandler%3CK, V%3E%3E(new Predicate%3CVoid%3E() %7B%0A                @Override%0A                public boolean eval(Void in) %7B%0A                    return false;%0A                %7D%0A            %7D, null, MapHandler.this, %22One or more key checks failed%22);%0A        %7D%0A%0A
     %7D%0A%0A    class
@@ -1717,32 +1717,370 @@
 his;%0A        %7D%0A%0A
+        public Chain%3CVoid, MapHandler%3CK,V%3E%3E all()%7B%0A            return new Chain%3CVoid, MapHandler%3CK, V%3E%3E(new Predicate%3CVoid%3E() %7B%0A                @Override%0A                public boolean eval(Void in) %7B%0A                    return false;%0A                %7D%0A            %7D, null, MapHandler.this, %22One or more value checks failed%22);%0A        %7D%0A%0A
     %7D%0A%0A    publi

Add all() to key,value handlers