Skip to content

Commit

Permalink
Merge pull request #717 from mP1/feature/Traversable-implements-CanBe…
Browse files Browse the repository at this point in the history
…Empty

Traversable implements CanBeEmpty
  • Loading branch information
mP1 authored Mar 25, 2024
2 parents ccde787 + e8ff558 commit 8c611f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/main/java/walkingkooka/tree/Traversable.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

package walkingkooka.tree;

import walkingkooka.CanBeEmpty;
import walkingkooka.Cast;

import java.util.Iterator;
Expand All @@ -26,7 +27,7 @@
/**
* A {@link Traversable} is part of a tree holding branches and leaves all of which are traversables.
*/
public interface Traversable<T extends Traversable<T>> {
public interface Traversable<T extends Traversable<T>> extends CanBeEmpty {

/**
* Standard index response to indicate a unsuccessful scan of an item in a list.
Expand Down Expand Up @@ -156,4 +157,14 @@ default Optional<T> lastChild() {
default Iterator<T> traversableIterator() {
return TraversableIterator.with(Cast.to(this));
}

// CanBeEmpty.......................................................................................................

/**
* Returns true if the children is empty
*/
@Override
default boolean isEmpty() {
return this.children().isEmpty();
}
}
2 changes: 2 additions & 0 deletions src/main/java/walkingkooka/tree/TraversableTesting2.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package walkingkooka.tree;

import org.junit.jupiter.api.Test;
import walkingkooka.CanBeEmptyTesting;
import walkingkooka.HashCodeEqualsDefinedTesting2;
import walkingkooka.ToStringTesting;
import walkingkooka.collect.list.Lists;
Expand All @@ -34,6 +35,7 @@
*/
public interface TraversableTesting2<T extends Traversable<T>>
extends BeanPropertiesTesting,
CanBeEmptyTesting<T>,
HashCodeEqualsDefinedTesting2<T>,
ToStringTesting<T>,
TraversableTesting,
Expand Down

0 comments on commit 8c611f5

Please sign in to comment.