View Javadoc
1   /*
2    * Copyright 2016 Function1. All Rights Reserved.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *    http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package tools.gsf.navigation;
17  
18  /**
19   * @author Freddy Villalba
20   * 
21   *
22   */
23  public interface ConfigurableNode<T extends Node<T>> {
24  	
25      
26      /**
27       * Add a child at the end of this node's list of children.
28       * 
29       * If children must be ordered in any particular way, it's the caller's responsibility to add them in the right order.
30       * 
31       * This method must be invoked BEFORE setParent. Calling it AFTER setParent will throw a runtime exception.
32       *  
33       * @param node
34       */
35      void addChild(T node);
36      
37      /**
38       * Can only be called once per instance. Otherwise, a runtime exception will be thrown.     
39       * @param node
40       */
41      void setParent(T node);
42      
43      /**
44       * Breaks the relationship between this node and all of its children, meaning:
45       * 
46       * - This node is not the parent of any of its children anymore.
47       * - The removed nodes are not this node's children anymore.
48       * 
49       */
50      void removeChildren();
51      
52      /**
53       * Breaks the relationship between this node and the specified child, meaning:
54       * 
55       * - This node is not the parent of the specified child anymore.
56       * - The removed node is not this node's child anymore.
57       * 
58       * The method returns true if the specified child was removed, false otherwise. 
59       * 
60       * @param child The child node we want to remove
61       * @return true if the node was removed, false otherwise
62       */
63      boolean removeChild(T child);
64  	
65  }