All Downloads are FREE. Search and download functionalities are using the official Maven repository.

se.europeanspallationsource.xaos.ui.control.tree.TreeItemPredicate Maven / Gradle / Ivy

Go to download

JavaFX-based portion of the XAOS framework, containing the JavaFX-based controls and tools suitable for other projects too.

The newest version!
/*
 * Copyright 2018 European Spallation Source ERIC.
 *
 * 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 se.europeanspallationsource.xaos.ui.control.tree;


import java.util.function.Predicate;
import javafx.scene.control.TreeItem;


/**
 * Represents a predicate (boolean-valued function) of two arguments: the first
 * is the parent {@link TreeItem} of the element subject of the function call,
 * and the second the value of element itself.
 * 

* This is a {@link FunctionalInterface} whose functional method is * {@link #test(TreeItem, Object)}. * * @param The type of the {@link TreeItem#getValue() value} property within * {@link TreeItem}. * @author [email protected] * @see Filtering a JavaFX TreeView */ @FunctionalInterface public interface TreeItemPredicate { /** * Evaluates this predicate on the given arguments. * * @param parent The parent {@link TreeItem} of the element or {@code null} if * there is no parent. * @param value The value to be tested. * @return {@code true} if the input argument matches the predicate. */ boolean test( TreeItem parent, T value ); /** * Utility method to create a {@link TreeItemPredicate} from a given * {@link Predicate}. * * @param The type of the value. * @param predicate The {@link Predicate} to be wrapped. * @return A new {@link TreeItemPredicate} wrapped around the given {@code predicate}. */ static TreeItemPredicate create( Predicate predicate ) { return ( parent, value ) -> predicate.test(value); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy