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

org.eclipse.fx.ui.controls.tree.TreeItemPredicate Maven / Gradle / Ivy

There is a newer version: 2.2.0
Show newest version
/*******************************************************************************
 * Copyright (c) 2014 EM-SOFTWARE and others.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *     Christoph Keimel  - initial API and implementation
 *******************************************************************************/
package org.eclipse.fx.ui.controls.tree;

import java.util.function.Predicate;

import javafx.scene.control.TreeItem;

/**
 * This interface can be used together with {@link FilterableTreeItem} to sort
 * the items in the list.
 *
 * @param 
 *            element type
 */
@FunctionalInterface
public interface TreeItemPredicate {

	/**
	 * Evaluates this predicate on the given argument.
	 *
	 * @param parent
	 *            the parent tree item of the element or null if there is no
	 *            parent
	 * @param value
	 *            the value to be tested
	 * @return {@code true} if the input argument matches the
	 *         predicate,otherwise {@code false}
	 */
	boolean test(TreeItem parent, T value);

	/**
	 * Utility method to create a TreeItemPredicate from a given
	 * {@link Predicate}
	 * 
	 * @param predicate
	 *            the predicate
	 * @return new TreeItemPredicate
	 */
	static  TreeItemPredicate create(Predicate predicate) {
		return (parent, value) -> predicate.test(value);
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy