brooklyn.entity.rebind.TreeUtils Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of brooklyn-core Show documentation
Show all versions of brooklyn-core Show documentation
Entity implementation classes, events, and other core elements
package brooklyn.entity.rebind;
import java.util.ArrayDeque;
import java.util.Collection;
import java.util.Deque;
import java.util.Set;
import brooklyn.location.Location;
import com.google.common.collect.Sets;
public class TreeUtils {
public static Collection findLocationsInHierarchy(Location root) {
Set result = Sets.newLinkedHashSet();
Deque tovisit = new ArrayDeque();
tovisit.addFirst(root);
while (tovisit.size() > 0) {
Location current = tovisit.pop();
result.add(current);
for (Location child : current.getChildren()) {
if (child != null) {
tovisit.push(child);
}
}
}
Location parentLocation = root.getParent();
while (parentLocation != null) {
result.add(parentLocation);
parentLocation = parentLocation.getParent();
}
return result;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy