-
Notifications
You must be signed in to change notification settings - Fork 2
/
item.go
54 lines (40 loc) · 854 Bytes
/
item.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
52
53
54
package main
import (
"encoding/json"
"fmt"
)
// Item that is either a solutions or a requirement
type Item interface {
json.Marshaler
ID() int64
UID() int64
SetUID(uid int64)
Version() int
Hash() [16]byte
Shown() bool
SetShown(shown bool)
Description() string
SetDescription(description string)
Pos() (int, int)
SetPos(x, y int)
Size() (int, int)
SetSize(w, h int)
AddChild(child Item)
RemoveChild(child Item)
Children() []Item
Parent() Item
SetParent(parent Item)
IsPropertyNull(columnName string) bool
ToString() string
}
func NewItem(id int64, itemType ItemType) Item {
var item Item
if itemType == TypeRequirement {
item = NewRequirement(id)
} else if itemType == TypeSolution {
item = NewSolution(id)
} else {
fmt.Println("error: failed to create item from id", id, "type", itemType)
}
return item
}