package net.ranides.assira.observable;

import lombok.RequiredArgsConstructor;
import net.ranides.assira.collection.prototype.GenericKey;
import net.ranides.assira.collection.prototype.GenericMap;
import net.ranides.assira.events.Event;

public interface GenericMapEvent<K> extends Event {

    GenericMap<K> map();

    @RequiredArgsConstructor
    class Remove<K> implements GenericMapEvent<K> {
        private final GenericMap<K> map;
        private final GenericKey<K,?> key;
        private final Object value;

        public GenericMap<K> map() {
            return map;
        }

        public GenericKey<K,?> key() {
            return key;
        }

        public Object value() {
            return value;
        }
    }

    @RequiredArgsConstructor
    class Clear<K> implements GenericMapEvent<K> {
        private final GenericMap<K> map;

        public GenericMap<K> map() {
            return map;
        }
    }

    @RequiredArgsConstructor
    class Put<K> implements GenericMapEvent<K> {
        private final GenericMap<K> map;
        private final GenericKey<K,?> key;
        private final Object previous;
        private final Object value;

        public GenericMap<K> map() {
            return map;
        }

        public GenericKey<K,?> key() {
            return key;
        }

        public Object previous() {
            return previous;
        }

        public Object value() {
            return value;
        }
    }

    @RequiredArgsConstructor
    class PutAll<K> implements GenericMapEvent<K> {
        private final GenericMap<K> map;
        private final GenericMap<? extends K> values;

        public GenericMap<K> map() {
            return map;
        }

        public GenericMap<? extends K> values() {
            return values;
        }
    }
}
