/
uiparametervisibility.go
108 lines (77 loc) · 3.25 KB
/
uiparametervisibility.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
package gaia
import (
"fmt"
"github.com/mitchellh/copystructure"
"go.aporeto.io/elemental"
)
// UIParameterVisibilityOperatorValue represents the possible values for attribute "operator".
type UIParameterVisibilityOperatorValue string
const (
// UIParameterVisibilityOperatorDefined represents the value Defined.
UIParameterVisibilityOperatorDefined UIParameterVisibilityOperatorValue = "Defined"
// UIParameterVisibilityOperatorEqual represents the value Equal.
UIParameterVisibilityOperatorEqual UIParameterVisibilityOperatorValue = "Equal"
// UIParameterVisibilityOperatorGreaterThan represents the value GreaterThan.
UIParameterVisibilityOperatorGreaterThan UIParameterVisibilityOperatorValue = "GreaterThan"
// UIParameterVisibilityOperatorLesserThan represents the value LesserThan.
UIParameterVisibilityOperatorLesserThan UIParameterVisibilityOperatorValue = "LesserThan"
// UIParameterVisibilityOperatorNotEqual represents the value NotEqual.
UIParameterVisibilityOperatorNotEqual UIParameterVisibilityOperatorValue = "NotEqual"
// UIParameterVisibilityOperatorUndefined represents the value Undefined.
UIParameterVisibilityOperatorUndefined UIParameterVisibilityOperatorValue = "Undefined"
)
// UIParameterVisibility represents the model of a uiparametervisibility
type UIParameterVisibility struct {
// Key holding the value to compare.
Key string `json:"key" msgpack:"key" bson:"key" mapstructure:"key,omitempty"`
// Operator to apply.
Operator UIParameterVisibilityOperatorValue `json:"operator" msgpack:"operator" bson:"operator" mapstructure:"operator,omitempty"`
// Values that must match the key.
Value interface{} `json:"value" msgpack:"value" bson:"value" mapstructure:"value,omitempty"`
ModelVersion int `json:"-" msgpack:"-" bson:"_modelversion"`
}
// NewUIParameterVisibility returns a new *UIParameterVisibility
func NewUIParameterVisibility() *UIParameterVisibility {
return &UIParameterVisibility{
ModelVersion: 1,
}
}
// BleveType implements the bleve.Classifier Interface.
func (o *UIParameterVisibility) BleveType() string {
return "uiparametervisibility"
}
// DeepCopy returns a deep copy if the UIParameterVisibility.
func (o *UIParameterVisibility) DeepCopy() *UIParameterVisibility {
if o == nil {
return nil
}
out := &UIParameterVisibility{}
o.DeepCopyInto(out)
return out
}
// DeepCopyInto copies the receiver into the given *UIParameterVisibility.
func (o *UIParameterVisibility) DeepCopyInto(out *UIParameterVisibility) {
target, err := copystructure.Copy(o)
if err != nil {
panic(fmt.Sprintf("Unable to deepcopy UIParameterVisibility: %s", err))
}
*out = *target.(*UIParameterVisibility)
}
// Validate valides the current information stored into the structure.
func (o *UIParameterVisibility) Validate() error {
errors := elemental.Errors{}
requiredErrors := elemental.Errors{}
if err := elemental.ValidateRequiredString("key", o.Key); err != nil {
requiredErrors = requiredErrors.Append(err)
}
if err := elemental.ValidateStringInList("operator", string(o.Operator), []string{"Equal", "NotEqual", "GreaterThan", "LesserThan", "Defined", "Undefined"}, false); err != nil {
errors = errors.Append(err)
}
if len(requiredErrors) > 0 {
return requiredErrors
}
if len(errors) > 0 {
return errors
}
return nil
}