-
-
Notifications
You must be signed in to change notification settings - Fork 19
/
graph_traversal.go
77 lines (65 loc) · 2.79 KB
/
graph_traversal.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
package sarif
// GraphTraversal ...
type GraphTraversal struct {
Description *Message `json:"description,omitempty"`
EdgeTraversals []*EdgeTraversal `json:"edgeTraversals,omitempty"`
ImmutableState map[string]*MultiformatMessageString `json:"immutableState,omitempty"`
InitialState map[string]*MultiformatMessageString `json:"initialState,omitempty"`
ResultGraphIndex *int `json:"resultGraphIndex,omitempty"`
RunGraphIndex *int `json:"runGraphIndex,omitempty"`
PropertyBag
}
// NewGraphTraversal creates a new GraphTraversal and returns a pointer to it
func NewGraphTraversal() *GraphTraversal {
return &GraphTraversal{}
}
// WithDescription sets the Description
func (graphTraversal *GraphTraversal) WithDescription(message *Message) *GraphTraversal {
graphTraversal.Description = message
return graphTraversal
}
// WithDescriptionText sets the DescriptionText
func (graphTraversal *GraphTraversal) WithDescriptionText(text string) *GraphTraversal {
if graphTraversal.Description == nil {
graphTraversal.Description = &Message{}
}
graphTraversal.Description.Text = &text
return graphTraversal
}
// WithDescriptionMarkdown sets the DescriptionMarkdown
func (graphTraversal *GraphTraversal) WithDescriptionMarkdown(markdown string) *GraphTraversal {
if graphTraversal.Description == nil {
graphTraversal.Description = &Message{}
}
graphTraversal.Description.Markdown = &markdown
return graphTraversal
}
// WithEdgeTraversals sets the EdgeTraversals
func (graphTraversal *GraphTraversal) WithEdgeTraversals(edgeTraversals []*EdgeTraversal) *GraphTraversal {
graphTraversal.EdgeTraversals = edgeTraversals
return graphTraversal
}
// AddEdge ...
func (graphTraversal *GraphTraversal) AddEdge(edgeTraversal *EdgeTraversal) {
graphTraversal.EdgeTraversals = append(graphTraversal.EdgeTraversals, edgeTraversal)
}
// WithResultGraphIndex sets the ResultGraphIndex
func (graphTraversal *GraphTraversal) WithResultGraphIndex(index int) *GraphTraversal {
graphTraversal.ResultGraphIndex = &index
return graphTraversal
}
// WithRunGraphIndex sets the RunGraphIndex
func (graphTraversal *GraphTraversal) WithRunGraphIndex(index int) *GraphTraversal {
graphTraversal.RunGraphIndex = &index
return graphTraversal
}
// WithImmutableState sets the ImmutableState
func (graphTraversal *GraphTraversal) WithImmutableState(immutableState map[string]*MultiformatMessageString) *GraphTraversal {
graphTraversal.ImmutableState = immutableState
return graphTraversal
}
// WithInitialState sets the InitialState
func (graphTraversal *GraphTraversal) WithInitialState(initialState map[string]*MultiformatMessageString) *GraphTraversal {
graphTraversal.InitialState = initialState
return graphTraversal
}