package net.ranides.assira.observable;

import lombok.RequiredArgsConstructor;
import net.ranides.assira.events.Event;

import java.util.Map;

public interface MapEvent<K,V> extends Event {

    Map<K,V> map();

    @RequiredArgsConstructor
    class Remove<K,V> implements MapEvent<K,V> {
        private final Map<K,V> map;
        private final K key;
        private final V value;

        public Map<K, V> map() {
            return map;
        }

        public K key() {
            return key;
        }

        public V value() {
            return value;
        }
    }

    @RequiredArgsConstructor
    class Clear<K,V> implements MapEvent<K,V> {
        private final Map<K,V> map;

        public Map<K, V> map() {
            return map;
        }
    }

    @RequiredArgsConstructor
    class Put<K,V> implements MapEvent<K,V> {
        private final Map<K,V> map;
        private final K key;
        private final V previous;
        private final V value;

        public Map<K, V> map() {
            return map;
        }

        public K key() {
            return key;
        }

        public V previous() {
            return previous;
        }

        public V value() {
            return value;
        }
    }

    @RequiredArgsConstructor
    class PutAll<K,V> implements MapEvent<K,V> {
        private final Map<K,V> map;
        private final Map<? extends K,? extends V> values;

        public Map<K, V> map() {
            return map;
        }

        public Map<? extends K,? extends V> values() {
            return values;
        }
    }
}
