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

org.solovyev.common.collections.tree.MutableTreeNode Maven / Gradle / Ivy

There is a newer version: 1.0.7
Show newest version
/*
 * Copyright 2013 serso aka se.solovyev
 *
 * 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.
 *
 * ---------------------------------------------------------------------
 * Contact details
 *
 * Email: [email protected]
 * Site:  http://se.solovyev.org
 */

package org.solovyev.common.collections.tree;

import org.solovyev.common.JPredicate;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.Collection;
import java.util.Iterator;

/**
 * User: serso
 * Date: 4/1/12
 * Time: 12:27 PM
 */

/**
 * Mutable interface of TreeNode
 */
public interface MutableTreeNode extends TreeNode {

	@Nullable
	MutableTreeNode findOwnChild(@Nonnull JPredicate> finder);

	void setValue(@Nullable T value);

	@Nonnull
	Collection> getOwnChildren();

	@Nonnull
	Iterator> getOwnChildrenIterator();

	@Nonnull
	Collection> getAllChildren();

	/**
	 * @param node node to be added. The parent specified in the node will be overwritten by this tree node
	 */
	void addChild(@Nonnull MutableTreeNode node);

	/**
	 * @param value data to be added in the node
	 * @return just added tree node
	 */
	@Nonnull
	MutableTreeNode addChild(@Nonnull T value);

	@Nonnull
	MutableTreeNode addChildIfNotExists(@Nonnull T value);

	/**
	 * Method removes from OWN children elements which are applied by predicate
	 *
	 * @param predicate removal condition
	 */
	void removeOwnChildIf(@Nonnull JPredicate> predicate);

	/**
	 * Method removes from ALL children elements which are applied by predicate
	 *
	 * @param predicate removal condition
	 */
	void removeChildIf(@Nonnull JPredicate> predicate);


	/**
	 * @param parent parent of current node
	 */
	void setParent(@Nullable TreeNode parent);
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy