-
Notifications
You must be signed in to change notification settings - Fork 1
/
permission.pb.fieldpath.go
767 lines (671 loc) · 25.1 KB
/
permission.pb.fieldpath.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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
// Code generated by protoc-gen-goten-object
// File: edgelq/iam/proto/v1alpha2/permission.proto
// DO NOT EDIT!!!
package permission
import (
"encoding/json"
"fmt"
"reflect"
"strings"
"time"
"github.com/iancoleman/strcase"
"google.golang.org/grpc/codes"
"google.golang.org/grpc/status"
"google.golang.org/protobuf/encoding/protojson"
"google.golang.org/protobuf/proto"
"google.golang.org/protobuf/reflect/protoregistry"
gotenobject "github.com/cloudwan/goten-sdk/runtime/object"
)
// proto imports
import (
meta "github.com/cloudwan/goten-sdk/types/meta"
)
// ensure the imports are used
var (
_ = new(json.Marshaler)
_ = new(fmt.Stringer)
_ = reflect.DeepEqual
_ = strings.Builder{}
_ = time.Second
_ = strcase.ToLowerCamel
_ = codes.NotFound
_ = status.Status{}
_ = protojson.UnmarshalOptions{}
_ = new(proto.Message)
_ = protoregistry.GlobalTypes
_ = new(gotenobject.FieldPath)
)
// make sure we're using proto imports
var (
_ = &meta.Meta{}
)
// FieldPath provides implementation to handle
// https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto
type Permission_FieldPath interface {
gotenobject.FieldPath
Selector() Permission_FieldPathSelector
Get(source *Permission) []interface{}
GetSingle(source *Permission) (interface{}, bool)
ClearValue(item *Permission)
// Those methods build corresponding Permission_FieldPathValue
// (or array of values) and holds passed value. Panics if injected type is incorrect.
WithIValue(value interface{}) Permission_FieldPathValue
WithIArrayOfValues(values interface{}) Permission_FieldPathArrayOfValues
WithIArrayItemValue(value interface{}) Permission_FieldPathArrayItemValue
}
type Permission_FieldPathSelector int32
const (
Permission_FieldPathSelectorName Permission_FieldPathSelector = 0
Permission_FieldPathSelectorTitle Permission_FieldPathSelector = 1
Permission_FieldPathSelectorDescription Permission_FieldPathSelector = 2
Permission_FieldPathSelectorMetadata Permission_FieldPathSelector = 3
)
func (s Permission_FieldPathSelector) String() string {
switch s {
case Permission_FieldPathSelectorName:
return "name"
case Permission_FieldPathSelectorTitle:
return "title"
case Permission_FieldPathSelectorDescription:
return "description"
case Permission_FieldPathSelectorMetadata:
return "metadata"
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", s))
}
}
func BuildPermission_FieldPath(fp gotenobject.RawFieldPath) (Permission_FieldPath, error) {
if len(fp) == 0 {
return nil, status.Error(codes.InvalidArgument, "empty field path for object Permission")
}
if len(fp) == 1 {
switch fp[0] {
case "name":
return &Permission_FieldTerminalPath{selector: Permission_FieldPathSelectorName}, nil
case "title":
return &Permission_FieldTerminalPath{selector: Permission_FieldPathSelectorTitle}, nil
case "description":
return &Permission_FieldTerminalPath{selector: Permission_FieldPathSelectorDescription}, nil
case "metadata":
return &Permission_FieldTerminalPath{selector: Permission_FieldPathSelectorMetadata}, nil
}
} else {
switch fp[0] {
case "metadata":
if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil {
return nil, err
} else {
return &Permission_FieldSubPath{selector: Permission_FieldPathSelectorMetadata, subPath: subpath}, nil
}
}
}
return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object Permission", fp)
}
func ParsePermission_FieldPath(rawField string) (Permission_FieldPath, error) {
fp, err := gotenobject.ParseRawFieldPath(rawField)
if err != nil {
return nil, err
}
return BuildPermission_FieldPath(fp)
}
func MustParsePermission_FieldPath(rawField string) Permission_FieldPath {
fp, err := ParsePermission_FieldPath(rawField)
if err != nil {
panic(err)
}
return fp
}
type Permission_FieldTerminalPath struct {
selector Permission_FieldPathSelector
}
var _ Permission_FieldPath = (*Permission_FieldTerminalPath)(nil)
func (fp *Permission_FieldTerminalPath) Selector() Permission_FieldPathSelector {
return fp.selector
}
// String returns path representation in proto convention
func (fp *Permission_FieldTerminalPath) String() string {
return fp.selector.String()
}
// JSONString returns path representation is JSON convention
func (fp *Permission_FieldTerminalPath) JSONString() string {
return strcase.ToLowerCamel(fp.String())
}
// Get returns all values pointed by specific field from source Permission
func (fp *Permission_FieldTerminalPath) Get(source *Permission) (values []interface{}) {
if source != nil {
switch fp.selector {
case Permission_FieldPathSelectorName:
if source.Name != nil {
values = append(values, source.Name)
}
case Permission_FieldPathSelectorTitle:
values = append(values, source.Title)
case Permission_FieldPathSelectorDescription:
values = append(values, source.Description)
case Permission_FieldPathSelectorMetadata:
if source.Metadata != nil {
values = append(values, source.Metadata)
}
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
return
}
func (fp *Permission_FieldTerminalPath) GetRaw(source proto.Message) []interface{} {
return fp.Get(source.(*Permission))
}
// GetSingle returns value pointed by specific field of from source Permission
func (fp *Permission_FieldTerminalPath) GetSingle(source *Permission) (interface{}, bool) {
switch fp.selector {
case Permission_FieldPathSelectorName:
res := source.GetName()
return res, res != nil
case Permission_FieldPathSelectorTitle:
return source.GetTitle(), source != nil
case Permission_FieldPathSelectorDescription:
return source.GetDescription(), source != nil
case Permission_FieldPathSelectorMetadata:
res := source.GetMetadata()
return res, res != nil
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
func (fp *Permission_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) {
return fp.GetSingle(source.(*Permission))
}
// GetDefault returns a default value of the field type
func (fp *Permission_FieldTerminalPath) GetDefault() interface{} {
switch fp.selector {
case Permission_FieldPathSelectorName:
return (*Name)(nil)
case Permission_FieldPathSelectorTitle:
return ""
case Permission_FieldPathSelectorDescription:
return ""
case Permission_FieldPathSelectorMetadata:
return (*meta.Meta)(nil)
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
func (fp *Permission_FieldTerminalPath) ClearValue(item *Permission) {
if item != nil {
switch fp.selector {
case Permission_FieldPathSelectorName:
item.Name = nil
case Permission_FieldPathSelectorTitle:
item.Title = ""
case Permission_FieldPathSelectorDescription:
item.Description = ""
case Permission_FieldPathSelectorMetadata:
item.Metadata = nil
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
}
func (fp *Permission_FieldTerminalPath) ClearValueRaw(item proto.Message) {
fp.ClearValue(item.(*Permission))
}
// IsLeaf - whether field path is holds simple value
func (fp *Permission_FieldTerminalPath) IsLeaf() bool {
return fp.selector == Permission_FieldPathSelectorName ||
fp.selector == Permission_FieldPathSelectorTitle ||
fp.selector == Permission_FieldPathSelectorDescription
}
func (fp *Permission_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath {
return []gotenobject.FieldPath{fp}
}
func (fp *Permission_FieldTerminalPath) WithIValue(value interface{}) Permission_FieldPathValue {
switch fp.selector {
case Permission_FieldPathSelectorName:
return &Permission_FieldTerminalPathValue{Permission_FieldTerminalPath: *fp, value: value.(*Name)}
case Permission_FieldPathSelectorTitle:
return &Permission_FieldTerminalPathValue{Permission_FieldTerminalPath: *fp, value: value.(string)}
case Permission_FieldPathSelectorDescription:
return &Permission_FieldTerminalPathValue{Permission_FieldTerminalPath: *fp, value: value.(string)}
case Permission_FieldPathSelectorMetadata:
return &Permission_FieldTerminalPathValue{Permission_FieldTerminalPath: *fp, value: value.(*meta.Meta)}
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
func (fp *Permission_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue {
return fp.WithIValue(value)
}
func (fp *Permission_FieldTerminalPath) WithIArrayOfValues(values interface{}) Permission_FieldPathArrayOfValues {
fpaov := &Permission_FieldTerminalPathArrayOfValues{Permission_FieldTerminalPath: *fp}
switch fp.selector {
case Permission_FieldPathSelectorName:
return &Permission_FieldTerminalPathArrayOfValues{Permission_FieldTerminalPath: *fp, values: values.([]*Name)}
case Permission_FieldPathSelectorTitle:
return &Permission_FieldTerminalPathArrayOfValues{Permission_FieldTerminalPath: *fp, values: values.([]string)}
case Permission_FieldPathSelectorDescription:
return &Permission_FieldTerminalPathArrayOfValues{Permission_FieldTerminalPath: *fp, values: values.([]string)}
case Permission_FieldPathSelectorMetadata:
return &Permission_FieldTerminalPathArrayOfValues{Permission_FieldTerminalPath: *fp, values: values.([]*meta.Meta)}
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
return fpaov
}
func (fp *Permission_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues {
return fp.WithIArrayOfValues(values)
}
func (fp *Permission_FieldTerminalPath) WithIArrayItemValue(value interface{}) Permission_FieldPathArrayItemValue {
switch fp.selector {
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fp.selector))
}
}
func (fp *Permission_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue {
return fp.WithIArrayItemValue(value)
}
type Permission_FieldSubPath struct {
selector Permission_FieldPathSelector
subPath gotenobject.FieldPath
}
var _ Permission_FieldPath = (*Permission_FieldSubPath)(nil)
func (fps *Permission_FieldSubPath) Selector() Permission_FieldPathSelector {
return fps.selector
}
func (fps *Permission_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) {
res, ok := fps.subPath.(meta.Meta_FieldPath)
return res, ok
}
// String returns path representation in proto convention
func (fps *Permission_FieldSubPath) String() string {
return fps.selector.String() + "." + fps.subPath.String()
}
// JSONString returns path representation is JSON convention
func (fps *Permission_FieldSubPath) JSONString() string {
return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString()
}
// Get returns all values pointed by selected field from source Permission
func (fps *Permission_FieldSubPath) Get(source *Permission) (values []interface{}) {
switch fps.selector {
case Permission_FieldPathSelectorMetadata:
values = append(values, fps.subPath.GetRaw(source.GetMetadata())...)
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fps.selector))
}
return
}
func (fps *Permission_FieldSubPath) GetRaw(source proto.Message) []interface{} {
return fps.Get(source.(*Permission))
}
// GetSingle returns value of selected field from source Permission
func (fps *Permission_FieldSubPath) GetSingle(source *Permission) (interface{}, bool) {
switch fps.selector {
case Permission_FieldPathSelectorMetadata:
if source.GetMetadata() == nil {
return nil, false
}
return fps.subPath.GetSingleRaw(source.GetMetadata())
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fps.selector))
}
}
func (fps *Permission_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) {
return fps.GetSingle(source.(*Permission))
}
// GetDefault returns a default value of the field type
func (fps *Permission_FieldSubPath) GetDefault() interface{} {
return fps.subPath.GetDefault()
}
func (fps *Permission_FieldSubPath) ClearValue(item *Permission) {
if item != nil {
switch fps.selector {
case Permission_FieldPathSelectorMetadata:
fps.subPath.ClearValueRaw(item.Metadata)
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fps.selector))
}
}
}
func (fps *Permission_FieldSubPath) ClearValueRaw(item proto.Message) {
fps.ClearValue(item.(*Permission))
}
// IsLeaf - whether field path is holds simple value
func (fps *Permission_FieldSubPath) IsLeaf() bool {
return fps.subPath.IsLeaf()
}
func (fps *Permission_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath {
iPaths := []gotenobject.FieldPath{&Permission_FieldTerminalPath{selector: fps.selector}}
iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...)
return iPaths
}
func (fps *Permission_FieldSubPath) WithIValue(value interface{}) Permission_FieldPathValue {
return &Permission_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)}
}
func (fps *Permission_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue {
return fps.WithIValue(value)
}
func (fps *Permission_FieldSubPath) WithIArrayOfValues(values interface{}) Permission_FieldPathArrayOfValues {
return &Permission_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)}
}
func (fps *Permission_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues {
return fps.WithIArrayOfValues(values)
}
func (fps *Permission_FieldSubPath) WithIArrayItemValue(value interface{}) Permission_FieldPathArrayItemValue {
return &Permission_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)}
}
func (fps *Permission_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue {
return fps.WithIArrayItemValue(value)
}
// Permission_FieldPathValue allows storing values for Permission fields according to their type
type Permission_FieldPathValue interface {
Permission_FieldPath
gotenobject.FieldPathValue
SetTo(target **Permission)
CompareWith(*Permission) (cmp int, comparable bool)
}
func ParsePermission_FieldPathValue(pathStr, valueStr string) (Permission_FieldPathValue, error) {
fp, err := ParsePermission_FieldPath(pathStr)
if err != nil {
return nil, err
}
fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "error parsing Permission field path value from %s: %v", valueStr, err)
}
return fpv.(Permission_FieldPathValue), nil
}
func MustParsePermission_FieldPathValue(pathStr, valueStr string) Permission_FieldPathValue {
fpv, err := ParsePermission_FieldPathValue(pathStr, valueStr)
if err != nil {
panic(err)
}
return fpv
}
type Permission_FieldTerminalPathValue struct {
Permission_FieldTerminalPath
value interface{}
}
var _ Permission_FieldPathValue = (*Permission_FieldTerminalPathValue)(nil)
// GetRawValue returns raw value stored under selected path for 'Permission' as interface{}
func (fpv *Permission_FieldTerminalPathValue) GetRawValue() interface{} {
return fpv.value
}
func (fpv *Permission_FieldTerminalPathValue) AsNameValue() (*Name, bool) {
res, ok := fpv.value.(*Name)
return res, ok
}
func (fpv *Permission_FieldTerminalPathValue) AsTitleValue() (string, bool) {
res, ok := fpv.value.(string)
return res, ok
}
func (fpv *Permission_FieldTerminalPathValue) AsDescriptionValue() (string, bool) {
res, ok := fpv.value.(string)
return res, ok
}
func (fpv *Permission_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) {
res, ok := fpv.value.(*meta.Meta)
return res, ok
}
// SetTo stores value for selected field for object Permission
func (fpv *Permission_FieldTerminalPathValue) SetTo(target **Permission) {
if *target == nil {
*target = new(Permission)
}
switch fpv.selector {
case Permission_FieldPathSelectorName:
(*target).Name = fpv.value.(*Name)
case Permission_FieldPathSelectorTitle:
(*target).Title = fpv.value.(string)
case Permission_FieldPathSelectorDescription:
(*target).Description = fpv.value.(string)
case Permission_FieldPathSelectorMetadata:
(*target).Metadata = fpv.value.(*meta.Meta)
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fpv.selector))
}
}
func (fpv *Permission_FieldTerminalPathValue) SetToRaw(target proto.Message) {
typedObject := target.(*Permission)
fpv.SetTo(&typedObject)
}
// CompareWith compares value in the 'Permission_FieldTerminalPathValue' with the value under path in 'Permission'.
func (fpv *Permission_FieldTerminalPathValue) CompareWith(source *Permission) (int, bool) {
switch fpv.selector {
case Permission_FieldPathSelectorName:
leftValue := fpv.value.(*Name)
rightValue := source.GetName()
if leftValue == nil {
if rightValue != nil {
return -1, true
}
return 0, true
}
if rightValue == nil {
return 1, true
}
if leftValue.String() == rightValue.String() {
return 0, true
} else if leftValue.String() < rightValue.String() {
return -1, true
} else {
return 1, true
}
case Permission_FieldPathSelectorTitle:
leftValue := fpv.value.(string)
rightValue := source.GetTitle()
if (leftValue) == (rightValue) {
return 0, true
} else if (leftValue) < (rightValue) {
return -1, true
} else {
return 1, true
}
case Permission_FieldPathSelectorDescription:
leftValue := fpv.value.(string)
rightValue := source.GetDescription()
if (leftValue) == (rightValue) {
return 0, true
} else if (leftValue) < (rightValue) {
return -1, true
} else {
return 1, true
}
case Permission_FieldPathSelectorMetadata:
return 0, false
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fpv.selector))
}
}
func (fpv *Permission_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) {
return fpv.CompareWith(source.(*Permission))
}
type Permission_FieldSubPathValue struct {
Permission_FieldPath
subPathValue gotenobject.FieldPathValue
}
var _ Permission_FieldPathValue = (*Permission_FieldSubPathValue)(nil)
func (fpvs *Permission_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) {
res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue)
return res, ok
}
func (fpvs *Permission_FieldSubPathValue) SetTo(target **Permission) {
if *target == nil {
*target = new(Permission)
}
switch fpvs.Selector() {
case Permission_FieldPathSelectorMetadata:
fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata)
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fpvs.Selector()))
}
}
func (fpvs *Permission_FieldSubPathValue) SetToRaw(target proto.Message) {
typedObject := target.(*Permission)
fpvs.SetTo(&typedObject)
}
func (fpvs *Permission_FieldSubPathValue) GetRawValue() interface{} {
return fpvs.subPathValue.GetRawValue()
}
func (fpvs *Permission_FieldSubPathValue) CompareWith(source *Permission) (int, bool) {
switch fpvs.Selector() {
case Permission_FieldPathSelectorMetadata:
return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata())
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fpvs.Selector()))
}
}
func (fpvs *Permission_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) {
return fpvs.CompareWith(source.(*Permission))
}
// Permission_FieldPathArrayItemValue allows storing single item in Path-specific values for Permission according to their type
// Present only for array (repeated) types.
type Permission_FieldPathArrayItemValue interface {
gotenobject.FieldPathArrayItemValue
Permission_FieldPath
ContainsValue(*Permission) bool
}
// ParsePermission_FieldPathArrayItemValue parses string and JSON-encoded value to its Value
func ParsePermission_FieldPathArrayItemValue(pathStr, valueStr string) (Permission_FieldPathArrayItemValue, error) {
fp, err := ParsePermission_FieldPath(pathStr)
if err != nil {
return nil, err
}
fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "error parsing Permission field path array item value from %s: %v", valueStr, err)
}
return fpaiv.(Permission_FieldPathArrayItemValue), nil
}
func MustParsePermission_FieldPathArrayItemValue(pathStr, valueStr string) Permission_FieldPathArrayItemValue {
fpaiv, err := ParsePermission_FieldPathArrayItemValue(pathStr, valueStr)
if err != nil {
panic(err)
}
return fpaiv
}
type Permission_FieldTerminalPathArrayItemValue struct {
Permission_FieldTerminalPath
value interface{}
}
var _ Permission_FieldPathArrayItemValue = (*Permission_FieldTerminalPathArrayItemValue)(nil)
// GetRawValue returns stored element value for array in object Permission as interface{}
func (fpaiv *Permission_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} {
return fpaiv.value
}
func (fpaiv *Permission_FieldTerminalPathArrayItemValue) GetSingle(source *Permission) (interface{}, bool) {
return nil, false
}
func (fpaiv *Permission_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) {
return fpaiv.GetSingle(source.(*Permission))
}
// Contains returns a boolean indicating if value that is being held is present in given 'Permission'
func (fpaiv *Permission_FieldTerminalPathArrayItemValue) ContainsValue(source *Permission) bool {
slice := fpaiv.Permission_FieldTerminalPath.Get(source)
for _, v := range slice {
if asProtoMsg, ok := fpaiv.value.(proto.Message); ok {
if proto.Equal(asProtoMsg, v.(proto.Message)) {
return true
}
} else if reflect.DeepEqual(v, fpaiv.value) {
return true
}
}
return false
}
type Permission_FieldSubPathArrayItemValue struct {
Permission_FieldPath
subPathItemValue gotenobject.FieldPathArrayItemValue
}
// GetRawValue returns stored array item value
func (fpaivs *Permission_FieldSubPathArrayItemValue) GetRawItemValue() interface{} {
return fpaivs.subPathItemValue.GetRawItemValue()
}
func (fpaivs *Permission_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) {
res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue)
return res, ok
}
// Contains returns a boolean indicating if value that is being held is present in given 'Permission'
func (fpaivs *Permission_FieldSubPathArrayItemValue) ContainsValue(source *Permission) bool {
switch fpaivs.Selector() {
case Permission_FieldPathSelectorMetadata:
return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata())
default:
panic(fmt.Sprintf("Invalid selector for Permission: %d", fpaivs.Selector()))
}
}
// Permission_FieldPathArrayOfValues allows storing slice of values for Permission fields according to their type
type Permission_FieldPathArrayOfValues interface {
gotenobject.FieldPathArrayOfValues
Permission_FieldPath
}
func ParsePermission_FieldPathArrayOfValues(pathStr, valuesStr string) (Permission_FieldPathArrayOfValues, error) {
fp, err := ParsePermission_FieldPath(pathStr)
if err != nil {
return nil, err
}
fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr)
if err != nil {
return nil, status.Errorf(codes.InvalidArgument, "error parsing Permission field path array of values from %s: %v", valuesStr, err)
}
return fpaov.(Permission_FieldPathArrayOfValues), nil
}
func MustParsePermission_FieldPathArrayOfValues(pathStr, valuesStr string) Permission_FieldPathArrayOfValues {
fpaov, err := ParsePermission_FieldPathArrayOfValues(pathStr, valuesStr)
if err != nil {
panic(err)
}
return fpaov
}
type Permission_FieldTerminalPathArrayOfValues struct {
Permission_FieldTerminalPath
values interface{}
}
var _ Permission_FieldPathArrayOfValues = (*Permission_FieldTerminalPathArrayOfValues)(nil)
func (fpaov *Permission_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) {
switch fpaov.selector {
case Permission_FieldPathSelectorName:
for _, v := range fpaov.values.([]*Name) {
values = append(values, v)
}
case Permission_FieldPathSelectorTitle:
for _, v := range fpaov.values.([]string) {
values = append(values, v)
}
case Permission_FieldPathSelectorDescription:
for _, v := range fpaov.values.([]string) {
values = append(values, v)
}
case Permission_FieldPathSelectorMetadata:
for _, v := range fpaov.values.([]*meta.Meta) {
values = append(values, v)
}
}
return
}
func (fpaov *Permission_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) {
res, ok := fpaov.values.([]*Name)
return res, ok
}
func (fpaov *Permission_FieldTerminalPathArrayOfValues) AsTitleArrayOfValues() ([]string, bool) {
res, ok := fpaov.values.([]string)
return res, ok
}
func (fpaov *Permission_FieldTerminalPathArrayOfValues) AsDescriptionArrayOfValues() ([]string, bool) {
res, ok := fpaov.values.([]string)
return res, ok
}
func (fpaov *Permission_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) {
res, ok := fpaov.values.([]*meta.Meta)
return res, ok
}
type Permission_FieldSubPathArrayOfValues struct {
Permission_FieldPath
subPathArrayOfValues gotenobject.FieldPathArrayOfValues
}
var _ Permission_FieldPathArrayOfValues = (*Permission_FieldSubPathArrayOfValues)(nil)
func (fpsaov *Permission_FieldSubPathArrayOfValues) GetRawValues() []interface{} {
return fpsaov.subPathArrayOfValues.GetRawValues()
}
func (fpsaov *Permission_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) {
res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues)
return res, ok
}