Created all necessary Add methods for source

This commit is contained in:
Jason Streifling 2024-10-20 10:42:12 +02:00
parent 4c38753ff7
commit e2986e70b1

View File

@ -28,6 +28,56 @@ func NewSource() *Source {
return &Source{CommonAttributes: newCommonAttributes()} 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 // Check checks the Source for incompatibilities with RFC4287. It returns an
// error. // error.
func (s *Source) Check() error { func (s *Source) Check() error {