@@ -7,19 +7,23 @@ const Wildcard = "-"
77// values and discriminators.
88type Hints struct {
99 DefaultNumType NumType
10- Enums HintSet
11- Values HintSet
12- Discriminator HintSet
10+ Enums * HintSet
11+ Values * HintSet
12+ Discriminator * HintSet
1313}
1414
15- // WithoutHints is a shorthand to return empty hints.
16- func WithoutHints () Hints {
17- return Hints {}
15+ // NewHints creates a new empty non nil `Hints`.
16+ func NewHints () * Hints {
17+ return & Hints {
18+ Enums : NewHintSet (),
19+ Values : NewHintSet (),
20+ Discriminator : NewHintSet (),
21+ }
1822}
1923
2024// SubHints will return the sub hints for all hint sets for the passed key.
21- func (h Hints ) SubHints (key string ) Hints {
22- return Hints {
25+ func (h Hints ) SubHints (key string ) * Hints {
26+ return & Hints {
2327 DefaultNumType : h .DefaultNumType ,
2428 Enums : h .Enums .SubHints (key ),
2529 Values : h .Values .SubHints (key ),
@@ -28,18 +32,18 @@ func (h Hints) SubHints(key string) Hints {
2832}
2933
3034// IsEnumActive checks if the enum hint set is active.
31- func (h Hints ) IsEnumActive () bool {
35+ func (h * Hints ) IsEnumActive () bool {
3236 return h .Enums .IsActive ()
3337}
3438
3539// IsValuesActive checks if the values hint set is active.
36- func (h Hints ) IsValuesActive () bool {
40+ func (h * Hints ) IsValuesActive () bool {
3741 return h .Values .IsActive ()
3842}
3943
4044// PeekActiveDiscriminator will peek the currently active discriminator, if any.
4145// The returned boolean tells if there is an active discriminator.
42- func (h Hints ) PeekActiveDiscriminator () (string , bool ) {
46+ func (h * Hints ) PeekActiveDiscriminator () (string , bool ) {
4347 return h .Discriminator .PeekActive ()
4448}
4549
@@ -49,21 +53,21 @@ type HintSet struct {
4953}
5054
5155// NewHintSet creates a new empty `HintSet`.
52- func NewHintSet () HintSet {
53- return HintSet {
56+ func NewHintSet () * HintSet {
57+ return & HintSet {
5458 Values : [][]string {},
5559 }
5660}
5761
5862// Add will add a path (slice) to the `HintSet`.
59- func (h HintSet ) Add (v []string ) HintSet {
63+ func (h * HintSet ) Add (v []string ) * HintSet {
6064 h .Values = append (h .Values , v )
6165 return h
6266}
6367
6468// SubHints will filter all the current sets and keep those who's first element
6569// matches the passed key or wildcard.
66- func (h HintSet ) SubHints (key string ) HintSet {
70+ func (h * HintSet ) SubHints (key string ) * HintSet {
6771 filteredValues := [][]string {}
6872
6973 for _ , values := range h .Values {
@@ -77,13 +81,13 @@ func (h HintSet) SubHints(key string) HintSet {
7781 }
7882 }
7983
80- return HintSet {
84+ return & HintSet {
8185 Values : filteredValues ,
8286 }
8387}
8488
8589// IsActive returns true if any set in the hint set his active.
86- func (h HintSet ) IsActive () bool {
90+ func (h * HintSet ) IsActive () bool {
8791 for _ , valueList := range h .Values {
8892 if len (valueList ) == 0 {
8993 return true
@@ -95,7 +99,7 @@ func (h HintSet) IsActive() bool {
9599
96100// PeekActive returns the currently active value if any. The returned boolean
97101// tells if a value was found.
98- func (h HintSet ) PeekActive () (string , bool ) {
102+ func (h * HintSet ) PeekActive () (string , bool ) {
99103 for _ , values := range h .Values {
100104 if len (values ) != 1 {
101105 continue
0 commit comments