Skip to content

Commit

Permalink
DOM: Pull up Serialize from ContainerBuilder to Container
Browse files Browse the repository at this point in the history
Signed-off-by: Richard Kosegi <richard.kosegi@gmail.com>
  • Loading branch information
rkosegi committed Jun 17, 2024
1 parent 122d8a6 commit dd8b0a3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions dom/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,10 @@ func (c *containerImpl) Children() map[string]Node {
return c.children
}

func (c *containerImpl) Serialize(writer io.Writer, mappingFunc NodeMappingFunc, encFn EncoderFunc) error {
return encFn(writer, mappingFunc(c))
}

func (c *containerImpl) Lookup(path string) Node {
if path == "" {
return nil
Expand Down Expand Up @@ -196,10 +200,6 @@ func (c *containerBuilderImpl) Remove(name string) {
delete(c.children, name)
}

func (c *containerBuilderImpl) Serialize(writer io.Writer, mappingFunc NodeMappingFunc, encFn EncoderFunc) error {
return encFn(writer, mappingFunc(c))
}

func (c *containerBuilderImpl) AddContainer(name string) ContainerBuilder {
cb := &containerBuilderImpl{}
c.add(name, cb)
Expand Down
2 changes: 1 addition & 1 deletion dom/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ type NodeList []Node
// Container is element that has zero or more child Nodes
type Container interface {
Node
Serializable
// Children returns mapping between child name and its corresponding Node
Children() map[string]Node
// Child returns single child Node by its name
Expand All @@ -125,7 +126,6 @@ type Container interface {
// ContainerBuilder is mutable extension of Container
type ContainerBuilder interface {
Container
Serializable
// AddValue adds Node value into this Container
AddValue(name string, value Node)
// AddValueAt adds Leaf value into this Container at given path.
Expand Down

0 comments on commit dd8b0a3

Please sign in to comment.