/**
 *
 * Copyright (c) 2006-2017, Speedment, Inc. All Rights Reserved.
 *
 * 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 com.speedment.tool.core.util;


import javafx.collections.ListChangeListener.Change;
import javafx.collections.ObservableList;
import javafx.collections.transformation.TransformationList;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;

/**
 * A list mapped to a transformation list.
 * 
 * @author        Emil Forslund
 * @param <FROM>  the type to map from
 * @param <TO>    the type to map to
 */
public final class MappedList<FROM, TO> extends TransformationList<TO, FROM> {

    private final Function<FROM, TO> mapper;

    public MappedList(ObservableList<? extends FROM> source, Function<FROM, TO> mapper) {
        super(source);
        this.mapper = mapper;
    }

    @Override
    public int getSourceIndex(int index) {
        return index;
    }

    @Override
    public TO get(int index) {
        return mapper.apply(getSource().get(index));
    }

    @Override
    public int size() {
        return getSource().size();
    }

    @Override
    protected void sourceChanged(Change<? extends FROM> c) {
        fireChange(new Change<TO>(this) {

            @Override
            public boolean wasAdded() {
                return c.wasAdded();
            }

            @Override
            public boolean wasRemoved() {
                return c.wasRemoved();
            }

            @Override
            public boolean wasReplaced() {
                return c.wasReplaced();
            }

            @Override
            public boolean wasUpdated() {
                return c.wasUpdated();
            }

            @Override
            public boolean wasPermutated() {
                return c.wasPermutated();
            }

            @Override
            public int getPermutation(int i) {
                return c.getPermutation(i);
            }

            @Override
            protected int[] getPermutation() {
                // This method is only called by the superclass methods
                // wasPermutated() and getPermutation(int), which are
                // both overriden by this class. There is no other way
                // this method can be called.
                throw new AssertionError("Unreachable code");
            }

            @Override
            public List<TO> getRemoved() {
                ArrayList<TO> res = new ArrayList<>(c.getRemovedSize());
                for (final FROM e : c.getRemoved()) {
                    res.add(mapper.apply(e));
                }
                return res;
            }

            @Override
            public int getFrom() {
                return c.getFrom();
            }

            @Override
            public int getTo() {
                return c.getTo();
            }

            @Override
            public boolean next() {
                return c.next();
            }

            @Override
            public void reset() {
                c.reset();
            }
        });
    }
}
@@ -868,24 +868,72 @@
 .util.List;%0A
+import static java.util.Objects.requireNonNull;%0A
 import java.
@@ -1381,22 +1381,38 @@
 apper = 
+requireNonNull(
 mapper
+)
 ;%0A    %7D%0A
@@ -1595,32 +1595,118 @@
 index));%0A    %7D%0A%0A
+    // Java 9 hack%0A    int getViewIndex(int index) %7B%0A        return index;%0A    %7D%0A    %0A
     @Override%0A  

Add method for Java 9 compatibility