From e2986e70b12deebedebe0e4f82da0f69a9c779b0 Mon Sep 17 00:00:00 2001 From: Jason Streifling Date: Sun, 20 Oct 2024 10:42:12 +0200 Subject: [PATCH] Created all necessary Add methods for source --- source.go | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/source.go b/source.go index 91ba816..1be908a 100644 --- a/source.go +++ b/source.go @@ -28,6 +28,56 @@ func NewSource() *Source { return &Source{CommonAttributes: newCommonAttributes()} } +// AddAuthor adds the Person as an author to the Entry. +func (s *Source) AddAuthor(p *Person) { + if s.Authors == nil { + s.Authors = make([]*Person, 1) + s.Authors[0] = p + } else { + s.Authors = append(s.Authors, p) + } +} + +// AddCategory adds the Category to the Entry. +func (s *Source) AddCategory(c *Category) { + if s.Categories == nil { + s.Categories = make([]*Category, 1) + s.Categories[0] = c + } else { + s.Categories = append(s.Categories, c) + } +} + +// AddContributor adds the Person as a contributor to the Entry. +func (s *Source) AddContributor(c *Person) { + if s.Contributors == nil { + s.Contributors = make([]*Person, 1) + s.Contributors[0] = c + } else { + s.Contributors = append(s.Contributors, c) + } +} + +// AddLink adds the Link to the Entry. +func (s *Source) AddLink(l *Link) { + if s.Links == nil { + s.Links = make([]*Link, 1) + s.Links[0] = l + } else { + s.Links = append(s.Links, l) + } +} + +// AddExtension adds the ExtensionElement to the Entry. +func (s *Source) AddExtension(e *ExtensionElement) { + if s.Extensions == nil { + s.Extensions = make([]*ExtensionElement, 1) + s.Extensions[0] = e + } else { + s.Extensions = append(s.Extensions, e) + } +} + // Check checks the Source for incompatibilities with RFC4287. It returns an // error. func (s *Source) Check() error {