Skip to content

Instantly share code, notes, and snippets.

@chetanmeh
Created August 13, 2014 15:05
Show Gist options
  • Save chetanmeh/2138c188a1bcc135eeb3 to your computer and use it in GitHub Desktop.
Save chetanmeh/2138c188a1bcc135eeb3 to your computer and use it in GitHub Desktop.
import com.google.common.base.Function
import com.google.common.collect.TreeTraverser
import org.apache.jackrabbit.oak.spi.state.NodeState
import static com.google.common.collect.Iterables.transform
def getChildCount(NodeState ns){
def traversor = {ns2 -> transform(ns2.childNodeEntries, {cne -> cne.nodeState} as Function)} as TreeTraverser
return traversor.preOrderTraversal(ns).size()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment