|
13 | 13 | // }
|
14 | 14 | //
|
15 | 15 | // // Provides type checking at compile time
|
16 |
| -// func (v *customInt) IntValue() int { |
| 16 | +// func (v *customInt) AsInt() int { |
17 | 17 | // return v.Int
|
18 | 18 | // }
|
19 | 19 | //
|
20 | 20 | // // Lets us return nil if we need to
|
21 |
| -// func (v *customInt) AnyValue() any { |
| 21 | +// func (v *customInt) AsAny() any { |
22 | 22 | // return v.Int
|
23 | 23 | // }
|
24 | 24 | //
|
@@ -68,79 +68,79 @@ var ValueGetter = func() expr.Option {
|
68 | 68 | // A custom type may implement both AnyValuer and a type specific interface to enable both
|
69 | 69 | // compile time checking and the ability to return a `nil` value.
|
70 | 70 | type AnyValuer interface {
|
71 |
| - AnyValue() any |
| 71 | + AsAny() any |
72 | 72 | }
|
73 | 73 |
|
74 | 74 | type IntValuer interface {
|
75 |
| - IntValue() int |
| 75 | + AsInt() int |
76 | 76 | }
|
77 | 77 |
|
78 | 78 | type BoolValuer interface {
|
79 |
| - BoolValue() bool |
| 79 | + AsBool() bool |
80 | 80 | }
|
81 | 81 |
|
82 | 82 | type Int8Valuer interface {
|
83 |
| - Int8Value() int8 |
| 83 | + AsInt8() int8 |
84 | 84 | }
|
85 | 85 |
|
86 | 86 | type Int16Valuer interface {
|
87 |
| - Int16Value() int16 |
| 87 | + AsInt16() int16 |
88 | 88 | }
|
89 | 89 |
|
90 | 90 | type Int32Valuer interface {
|
91 |
| - Int32Value() int32 |
| 91 | + AsInt32() int32 |
92 | 92 | }
|
93 | 93 |
|
94 | 94 | type Int64Valuer interface {
|
95 |
| - Int64Value() int64 |
| 95 | + AsInt64() int64 |
96 | 96 | }
|
97 | 97 |
|
98 | 98 | type UintValuer interface {
|
99 |
| - UintValue() uint |
| 99 | + AsUint() uint |
100 | 100 | }
|
101 | 101 |
|
102 | 102 | type Uint8Valuer interface {
|
103 |
| - Uint8Value() uint8 |
| 103 | + AsUint8() uint8 |
104 | 104 | }
|
105 | 105 |
|
106 | 106 | type Uint16Valuer interface {
|
107 |
| - Uint16Value() uint16 |
| 107 | + AsUint16() uint16 |
108 | 108 | }
|
109 | 109 |
|
110 | 110 | type Uint32Valuer interface {
|
111 |
| - Uint32Value() uint32 |
| 111 | + AsUint32() uint32 |
112 | 112 | }
|
113 | 113 |
|
114 | 114 | type Uint64Valuer interface {
|
115 |
| - Uint64Value() uint64 |
| 115 | + AsUint64() uint64 |
116 | 116 | }
|
117 | 117 |
|
118 | 118 | type Float32Valuer interface {
|
119 |
| - Float32Value() float32 |
| 119 | + AsFloat32() float32 |
120 | 120 | }
|
121 | 121 |
|
122 | 122 | type Float64Valuer interface {
|
123 |
| - Float64Value() float64 |
| 123 | + AsFloat64() float64 |
124 | 124 | }
|
125 | 125 |
|
126 | 126 | type StringValuer interface {
|
127 |
| - StringValue() string |
| 127 | + AsString() string |
128 | 128 | }
|
129 | 129 |
|
130 | 130 | type TimeValuer interface {
|
131 |
| - TimeValue() time.Time |
| 131 | + AsTime() time.Time |
132 | 132 | }
|
133 | 133 |
|
134 | 134 | type DurationValuer interface {
|
135 |
| - DurationValue() time.Duration |
| 135 | + AsDuration() time.Duration |
136 | 136 | }
|
137 | 137 |
|
138 | 138 | type ArrayValuer interface {
|
139 |
| - ArrayValue() []any |
| 139 | + AsArray() []any |
140 | 140 | }
|
141 | 141 |
|
142 | 142 | type MapValuer interface {
|
143 |
| - MapValue() map[string]any |
| 143 | + AsMap() map[string]any |
144 | 144 | }
|
145 | 145 |
|
146 | 146 | var supportedInterfaces = []reflect.Type{
|
@@ -194,43 +194,43 @@ func (patcher) ApplyOptions(c *conf.Config) {
|
194 | 194 | func getValue(params ...any) (any, error) {
|
195 | 195 | switch v := params[0].(type) {
|
196 | 196 | case AnyValuer:
|
197 |
| - return v.AnyValue(), nil |
| 197 | + return v.AsAny(), nil |
198 | 198 | case BoolValuer:
|
199 |
| - return v.BoolValue(), nil |
| 199 | + return v.AsBool(), nil |
200 | 200 | case IntValuer:
|
201 |
| - return v.IntValue(), nil |
| 201 | + return v.AsInt(), nil |
202 | 202 | case Int8Valuer:
|
203 |
| - return v.Int8Value(), nil |
| 203 | + return v.AsInt8(), nil |
204 | 204 | case Int16Valuer:
|
205 |
| - return v.Int16Value(), nil |
| 205 | + return v.AsInt16(), nil |
206 | 206 | case Int32Valuer:
|
207 |
| - return v.Int32Value(), nil |
| 207 | + return v.AsInt32(), nil |
208 | 208 | case Int64Valuer:
|
209 |
| - return v.Int64Value(), nil |
| 209 | + return v.AsInt64(), nil |
210 | 210 | case UintValuer:
|
211 |
| - return v.UintValue(), nil |
| 211 | + return v.AsUint(), nil |
212 | 212 | case Uint8Valuer:
|
213 |
| - return v.Uint8Value(), nil |
| 213 | + return v.AsUint8(), nil |
214 | 214 | case Uint16Valuer:
|
215 |
| - return v.Uint16Value(), nil |
| 215 | + return v.AsUint16(), nil |
216 | 216 | case Uint32Valuer:
|
217 |
| - return v.Uint32Value(), nil |
| 217 | + return v.AsUint32(), nil |
218 | 218 | case Uint64Valuer:
|
219 |
| - return v.Uint64Value(), nil |
| 219 | + return v.AsUint64(), nil |
220 | 220 | case Float32Valuer:
|
221 |
| - return v.Float32Value(), nil |
| 221 | + return v.AsFloat32(), nil |
222 | 222 | case Float64Valuer:
|
223 |
| - return v.Float64Value(), nil |
| 223 | + return v.AsFloat64(), nil |
224 | 224 | case StringValuer:
|
225 |
| - return v.StringValue(), nil |
| 225 | + return v.AsString(), nil |
226 | 226 | case TimeValuer:
|
227 |
| - return v.TimeValue(), nil |
| 227 | + return v.AsTime(), nil |
228 | 228 | case DurationValuer:
|
229 |
| - return v.DurationValue(), nil |
| 229 | + return v.AsDuration(), nil |
230 | 230 | case ArrayValuer:
|
231 |
| - return v.ArrayValue(), nil |
| 231 | + return v.AsArray(), nil |
232 | 232 | case MapValuer:
|
233 |
| - return v.MapValue(), nil |
| 233 | + return v.AsMap(), nil |
234 | 234 | }
|
235 | 235 |
|
236 | 236 | return params[0], nil
|
|
0 commit comments