summaryrefslogtreecommitdiffstats
path: root/server/src/main
diff options
context:
space:
mode:
authorAdam Wagner <wbadam@users.noreply.github.com>2017-07-27 14:09:28 +0300
committerHenri Sara <henri.sara@gmail.com>2017-07-27 14:09:28 +0300
commit42f7eba5e70c7ae2f3958f4e75e196dedfacc9c3 (patch)
tree9b571d45a43f01373f0dc47aa4e2e4a979f22eb1 /server/src/main
parent390fd31dc18d026a60a89e9b5cba040859cc3393 (diff)
downloadvaadin-framework-42f7eba5e70c7ae2f3958f4e75e196dedfacc9c3.tar.gz
vaadin-framework-42f7eba5e70c7ae2f3958f4e75e196dedfacc9c3.zip
Add method to get parent in TreeData (#9701)
Diffstat (limited to 'server/src/main')
-rw-r--r--server/src/main/java/com/vaadin/data/TreeData.java19
1 files changed, 19 insertions, 0 deletions
diff --git a/server/src/main/java/com/vaadin/data/TreeData.java b/server/src/main/java/com/vaadin/data/TreeData.java
index bebf312614..1a5b0e4d3a 100644
--- a/server/src/main/java/com/vaadin/data/TreeData.java
+++ b/server/src/main/java/com/vaadin/data/TreeData.java
@@ -368,6 +368,25 @@ public class TreeData<T> implements Serializable {
}
/**
+ * Get the parent item for the given item.
+ *
+ * @param item
+ * the item for which to retrieve the parent item for
+ * @return parent item for the given item or {@code null} if the item is a
+ * root item.
+ * @throws IllegalArgumentException
+ * if the item does not exist in this structure
+ * @since 8.1.1
+ */
+ public T getParent(T item) {
+ if (!contains(item)) {
+ throw new IllegalArgumentException(
+ "Item '" + item + "' not in hierarchy");
+ }
+ return itemToWrapperMap.get(item).getParent();
+ }
+
+ /**
* Moves an item to become a child of the given parent item. The new parent
* item must exist in the hierarchy. Setting the parent to {@code null}
* makes the item a root item. After making changes to the tree data, {@link