/*
 * Copyright 2008-2017 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package griffon.javafx.collections;

import com.sun.javafx.collections.SetListenerHelper;
import javafx.beans.InvalidationListener;
import javafx.collections.ObservableSet;
import javafx.collections.SetChangeListener;

import java.util.AbstractSet;

/**
 * @author Andres Almiray
 * @since 2.9.0
 */
public abstract class ObservableSetBase<E> extends AbstractSet<E> implements ObservableSet<E> {
    private SetListenerHelper<E> listenerHelper;

    @Override
    public final void addListener(InvalidationListener listener) {
        listenerHelper = SetListenerHelper.addListener(listenerHelper, listener);
    }

    @Override
    public final void removeListener(InvalidationListener listener) {
        listenerHelper = SetListenerHelper.removeListener(listenerHelper, listener);
    }

    @Override
    public final void addListener(SetChangeListener<? super E> listener) {
        listenerHelper = SetListenerHelper.addListener(listenerHelper, listener);
    }

    @Override
    public final void removeListener(SetChangeListener<? super E> listener) {
        listenerHelper = SetListenerHelper.removeListener(listenerHelper, listener);
    }

    protected final void fireChange(SetChangeListener.Change<? extends E> change) {
        SetListenerHelper.fireValueChangedEvent(listenerHelper, change);
    }

    /**
     * Returns true if there are some listeners registered for this list.
     */
    protected final boolean hasListeners() {
        return SetListenerHelper.hasListeners(listenerHelper);
    }
}

@@ -847,25 +847,107 @@
 java
-.util.AbstractSet
+x.annotation.Nonnull;%0Aimport java.util.AbstractSet;%0A%0Aimport static java.util.Objects.requireNonNull
 ;%0A%0A/
@@ -2144,24 +2144,24 @@
 steners() %7B%0A
-
         retu
@@ -2216,11 +2216,1707 @@
 );%0A    %7D
+%0A%0A    public static class BaseAddChange%3CT%3E extends SetChangeListener.Change%3CT%3E %7B%0A        private final T added;%0A%0A        public BaseAddChange(@Nonnull ObservableSet%3CT%3E set, @Nonnull T added) %7B%0A            super(requireNonNull(set, %22Argument 'set' must not be null%22));%0A            this.added = requireNonNull(added, %22Argument 'added' must not be null%22);%0A        %7D%0A%0A        @Override%0A        public boolean wasAdded() %7B%0A            return true;%0A        %7D%0A%0A        @Override%0A        public boolean wasRemoved() %7B%0A            return false;%0A        %7D%0A%0A        @Override%0A        public T getElementAdded() %7B%0A            return added;%0A        %7D%0A%0A        @Override%0A        public T getElementRemoved() %7B%0A            return null;%0A        %7D%0A%0A        @Override%0A        public String toString() %7B%0A            return %22added %22 + added;%0A        %7D%0A    %7D%0A%0A    public static class BaseRemoveChange%3CT%3E extends SetChangeListener.Change%3CT%3E %7B%0A        private final T removed;%0A%0A        public BaseRemoveChange(@Nonnull ObservableSet%3CT%3E set, @Nonnull T removed) %7B%0A            super(requireNonNull(set, %22Argument 'set' must not be null%22));%0A            this.removed = requireNonNull(removed, %22Argument 'removed' must not be null%22);%0A        %7D%0A%0A        @Override%0A        public boolean wasAdded() %7B%0A            return false;%0A        %7D%0A%0A        @Override%0A        public boolean wasRemoved() %7B%0A            return true;%0A        %7D%0A%0A        @Override%0A        public T getElementAdded() %7B%0A            return null;%0A        %7D%0A%0A        @Override%0A        public T getElementRemoved() %7B%0A            return removed;%0A        %7D%0A%0A        @Override%0A        public String toString() %7B%0A            return %22removed %22 + removed;%0A        %7D%0A    %7D
 %0A%7D%0A

Add base SetChangeListener implementations