-
Notifications
You must be signed in to change notification settings - Fork 22
/
birth_node.go
51 lines (44 loc) · 1.31 KB
/
birth_node.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package gedcom
// BirthNode is the event of entering into life.
type BirthNode struct {
*SimpleNode
}
// NewBirthNode creates a new BIRT node.
func NewBirthNode(value string, children ...Node) *BirthNode {
return &BirthNode{
newSimpleNode(TagBirth, value, "", children...),
}
}
// Dates returns zero or more dates associated with the Birth.
//
// When more than one date is returned you should not assume that the order has
// any significance for the importance of the dates.
//
// If the node is nil the result will also be nil.
func (node *BirthNode) Dates() DateNodes {
return Dates(node)
}
// Equal will always return true if both nodes are not nil.
//
// If either node is nil (including both) or if the right side is not a
// BirthNode then false is always returned. Otherwise Equals will always return
// true.
//
// The reason Equals always returns true is because Equals is a shallow test and
// an individual can only ever have one birth event. Therefore it is safe to
// assume that birth events themselves are equal, even if the children they
// contain are not.
//
// This logic is especially important for CompareNodes.
func (node *BirthNode) Equals(node2 Node) bool {
if IsNil(node) {
return false
}
if IsNil(node2) {
return false
}
if _, ok := node2.(*BirthNode); !ok {
return false
}
return true
}