Skip to content

Commit

Permalink
feat(core): add ListNode#addList and ListNode#addMap
Browse files Browse the repository at this point in the history
  • Loading branch information
Siroshun09 committed Nov 3, 2023
1 parent 9a7b045 commit c5d75eb
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,28 @@ public sealed interface ListNode extends Node<List<Node<?>>> permits ListNodeImp
*/
void add(@NotNull Object value);

/**
* Adds a new {@link ListNode} to this {@link ListNode}.
*
* @return a created {@link ListNode}
*/
@NotNull ListNode addList();

/**
* Adds a new {@link ListNode} to this {@link ListNode}.
*
* @param initialCapacity the initial capacity of the list
* @return a created {@link ListNode}
*/
@NotNull ListNode addList(int initialCapacity);

/**
* Adds a new {@link MapNode} to this {@link ListNode}.
*
* @return a created {@link MapNode}
*/
@NotNull MapNode addMap();

/**
* Removes an object from this {@link ListNode}.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,27 @@ public void add(@NotNull Object value) {
this.backing.add(Node.fromObject(value));
}

@Override
public @NotNull ListNode addList() {
var listNode = ListNode.create();
this.backing.add(listNode);
return listNode;
}

@Override
public @NotNull ListNode addList(int initialCapacity) {
var listNode = ListNode.create(initialCapacity);
this.backing.add(listNode);
return listNode;
}

@Override
public @NotNull MapNode addMap() {
var listNode = MapNode.create();
this.backing.add(listNode);
return listNode;
}

@Override
public void remove(@NotNull Object value) {
this.backing.remove(Node.fromObject(value));
Expand Down

0 comments on commit c5d75eb

Please sign in to comment.