Package jsx.ui

Source Code of jsx.ui.BindingHelper

/*
* Copyright (C) 2014 Nameless Production Committee
*
* Licensed under the MIT License (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
*          http://opensource.org/licenses/mit-license.php
*/
package jsx.ui;

import java.util.function.Predicate;

import javafx.beans.property.ListProperty;
import javafx.beans.property.SimpleListProperty;
import javafx.collections.transformation.FilteredList;

/**
* @version 2014/10/02 12:40:07
*/
public class BindingHelper {

    /**
     * @param list
     * @param object
     * @return
     */
    public static <T> ListProperty<T> filter(ListProperty<T> list, Predicate<T> filter) {
        FilteredList<T> filtered = list.filtered(filter);
        ModelInspector<T> inspector = new ModelInspector(filtered);

        list.addListener(inspector);

        for (T item : list) {
            inspector.inspect(item);
        }
        return new SimpleListProperty(filtered);
    }
}
TOP

Related Classes of jsx.ui.BindingHelper

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.