- DefinedTerm is ordered as in enum (#3752)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / ITreeNode.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10 package eu.etaxonomy.cdm.model.common;
11
12 import java.util.Collection;
13 import java.util.List;
14
15 import org.hibernate.event.spi.SaveOrUpdateEventListener;
16
17 /**
18 * Common interface for all tree data structures supporting tree indexing.
19 * Mainly used by {@link SaveOrUpdateEventListener} to update the indices.
20 *
21 * @author a.mueller
22 * @created 12.08.2013
23 *
24 */
25 public interface ITreeNode<T extends ITreeNode<T>> extends ICdmBase {
26
27 //Constants
28 //the separator used in the tree index to separate the id's of the parent nodes
29 public static final String separator = "#";
30
31 //The prefix used in the tree index for the id of the tree itself
32 public static final String treePrefix = "t";
33
34
35 //METHODS
36
37
38 /**
39 * Returns the tree index of this tree node.
40 * @return the tree index
41 */
42 public String treeIndex();
43
44
45 /**
46 * Returns the parent node of this node.
47 * Returns <code>null</code> if this
48 * node is a root node.
49 * @return
50 */
51 public ITreeNode<T> getParent();
52
53 /**
54 * Sets the tree index of this node.
55 * @deprecated preliminary implementation for updating the treeindex.
56 * Maybe removed once index updating is improved.
57 * @param newTreeIndex
58 */
59 public void setTreeIndex(String newTreeIndex);
60
61 /**
62 * Returns all direct child nodes of this node.
63 * As tree node children do not necessarily need to be
64 * {@link List lists} the return type of this method may change
65 * to {@link Collection} in future. Therefore the use
66 * at the moment is deprecated.
67 * @deprecated return type may become {@link Collection} in future
68 * @return the list of children
69 */
70 public List<T> getChildNodes();
71
72 /**
73 * Returns the {@link ICdmBase#getId() id} of the tree object,
74 * this node belongs to.
75 * @deprecated may be removed in future when index updating does not
76 * use this anymore
77 * @return the id of the tree
78 */
79 public int treeId();
80
81 }