Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DOM: Pull up Serialize from ContainerBuilder to Container #35

Merged
merged 1 commit into from
Jun 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading