forked from tliron/puccini
-
Notifications
You must be signed in to change notification settings - Fork 0
/
list.go
52 lines (40 loc) · 1.47 KB
/
list.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
package normal
import (
"github.com/tliron/puccini/tosca"
)
//
// List
//
type List struct {
Key Constrainable `json:"$key,omitempty" yaml:"$key,omitempty"`
Information *ValueInformation `json:"$information,omitempty" yaml:"$information,omitempty"`
Constraints FunctionCalls `json:"$constraints,omitempty" yaml:"$constraints,omitempty"`
Converter *FunctionCall `json:"$converter,omitempty" yaml:"$converter,omitempty"`
EntryConstraints FunctionCalls `json:"$entryConstraints,omitempty" yaml:"$entryConstraints,omitempty"`
Entries ConstrainableList `json:"$list" yaml:"$list"`
}
func NewList(length int) *List {
return &List{Entries: make(ConstrainableList, length)}
}
// Constrainable interface
func (self *List) SetKey(key Constrainable) {
self.Key = key
}
// Constrainable interface
func (self *List) SetInformation(information *ValueInformation) {
self.Information = CopyValueInformation(information)
}
// Constrainable interface
func (self *List) AddConstraint(functionCall *tosca.FunctionCall) {
self.Constraints = append(self.Constraints, NewFunctionCall(functionCall))
}
// Constrainable interface
func (self *List) SetConverter(converter *tosca.FunctionCall) {
self.Converter = NewFunctionCall(converter)
}
func (self *List) AddEntryConstraint(constraint *tosca.FunctionCall) {
self.EntryConstraints = append(self.EntryConstraints, NewFunctionCall(constraint))
}
func (self *List) Set(index int, value Constrainable) {
self.Entries[index] = value
}