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