-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcategory.go
111 lines (96 loc) · 2.16 KB
/
category.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
package hpcmodel
type QueryCategory struct {
ID string
DisplayName string
Label string
ParseRecord RecordParser
RecordParserClass string
RecordParserArguments []string
PropertyClass string
PropertyCreateArguments []string
}
func (q1 *QueryCategory) Equal(q2 *QueryCategory) bool {
if q1 == nil && q2 == nil {
return true
}
if q1.ID != q2.ID {
return false
}
if q1.DisplayName != q2.DisplayName {
return false
}
if q1.RecordParserClass != q2.RecordParserClass {
return false
}
if len(q1.RecordParserArguments) != len(q2.RecordParserArguments) {
return false
}
for i, arg := range q1.RecordParserArguments {
if arg != q2.RecordParserArguments[i] {
return false
}
}
if q1.PropertyClass != q2.PropertyClass {
return false
}
if len(q1.PropertyCreateArguments) != len(q2.PropertyCreateArguments) {
return false
}
for i2, arg2 := range q1.PropertyCreateArguments {
if arg2 != q2.PropertyCreateArguments[i2] {
return false
}
}
return true
}
type QueryCategoryList struct {
CategoryList []*QueryCategory
}
func (ql *QueryCategoryList) ContainsID(id string) bool {
for _, category := range ql.CategoryList {
if category.ID == id {
return true
}
}
return false
}
func (ql *QueryCategoryList) IndexFromId(id string) int {
for index, category := range ql.CategoryList {
if category.ID == id {
return index
}
}
return -1
}
func (ql *QueryCategoryList) CategoryFromId(id string) *QueryCategory {
for _, category := range ql.CategoryList {
if category.ID == id {
return category
}
}
return nil
}
func (ql *QueryCategoryList) ContainsLabel(label string) bool {
for _, category := range ql.CategoryList {
if category.Label == label {
return true
}
}
return false
}
func (ql *QueryCategoryList) IndexFromLabel(label string) int {
for index, category := range ql.CategoryList {
if category.Label == label {
return index
}
}
return -1
}
func (ql *QueryCategoryList) CategoryFromLabel(label string) *QueryCategory {
for _, category := range ql.CategoryList {
if category.Label == label {
return category
}
}
return nil
}