public static RevTree create(final ObjectId id, final long size, final int childTreeCount, @Nullable ImmutableList<Node> trees, @Nullable ImmutableList<Node> features, @Nullable ImmutableSortedMap<Integer, Bucket> buckets) { checkNotNull(id); if (buckets == null || buckets.isEmpty()) { return new LeafTree(id, size, features, trees); } if ((features == null || features.isEmpty()) && (trees == null || trees.isEmpty())) { return new NodeTree(id, size, childTreeCount, buckets); } throw new IllegalArgumentException( "Mixed (containing nodes and buckets) trees are not supported"); }
public @Override int treesSize() { return numTrees();// being a leaf tree, numTrees and treesSize are the same }
public @Override @NonNull RevTree createTree(final @NonNull ObjectId id, final long size, @NonNull List<Node> trees, @NonNull List<Node> features) { if (size < 0L) { throw new IllegalArgumentException("Cannot create a tree with negative size: " + size); } Node[] f = features.isEmpty() ? null : features.toArray(new Node[features.size()]); Node[] t = trees.isEmpty() ? null : trees.toArray(new Node[trees.size()]); checkNodes(t, TYPE.TREE); checkNodes(f, TYPE.FEATURE); return new LeafTree(id, size, f, t); }