/**
 *  Licensed to the Apache Software Foundation (ASF) under one
 *  or more contributor license agreements.  See the NOTICE file
 *  distributed with this work for additional information
 *  regarding copyright ownership.  The ASF licenses this file
 *  to you 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 org.libraryweasel.traytable;

import javafx.beans.property.ReadOnlyStringWrapper;
import javafx.scene.control.TableColumn;
import javafx.scene.control.TableView;

import java.util.List;

public final class TrayTable {
    public static TableView<List<String>> create(List<String> headers, List<List<String>> content) {
        TableView<List<String>> table = new TableView<>();

        for (int index = 0; index < headers.size(); index++) {
            String columnTitle = headers.get(index);
            TableColumn<List<String>, String> column = new TableColumn<>(columnTitle);
            table.getColumns().add(column);
            final int current = index;
            column.setCellValueFactory(row -> {
                if (current < row.getValue().size()) {
                    return new ReadOnlyStringWrapper(row.getValue().get(current));
                } else {
                    return new ReadOnlyStringWrapper("");
                }
            });
        }
        table.getItems().addAll(content);
        return table;
    }
}

@@ -1009,16 +1009,51 @@
 il.List;
+%0Aimport java.util.stream.IntStream;
 %0A%0Apublic
@@ -1182,24 +1182,30 @@
 ) %7B%0A        
+final 
 TableView%3CLi
@@ -1256,115 +1256,73 @@
     
-for (int index = 0; index %3C headers.size(); index++) %7B%0A            String columnTitle = headers.get(
+IntStream.range(0, headers.size()).forEach((final int 
 index)
-;
+ -%3E %7B
 %0A   
@@ -1330,16 +1330,22 @@
         
+final 
 TableCol
@@ -1401,19 +1401,26 @@
 n%3C%3E(
-columnTitle
+headers.get(index)
 );%0A 
@@ -1466,47 +1466,8 @@
 n);%0A
-            final int current = index;%0A
     
@@ -1507,18 +1507,16 @@
 y(row -%3E
- %7B
 %0A       
@@ -1528,74 +1528,8 @@
     
-if (current %3C row.getValue().size()) %7B%0A                    return 
 new 
@@ -1550,16 +1550,25 @@
 Wrapper(
+(index %3C 
 row.getV
@@ -1578,128 +1578,52 @@
 e().
-get(current));%0A                %7D else %7B%0A                    return new ReadOnlyStringWrapper(
+size()) ? row.getValue().get(index) : 
 %22%22)
+)
 ;%0A
-                %7D%0A    
     
@@ -1634,18 +1634,8 @@
 %7D);%0A
-        %7D%0A
     

clean up closes #3