github.com/cloudwan/edgelq-sdk@v1.15.4/iam/resources/v1alpha2/condition/condition.pb.fieldmask.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/iam/proto/v1alpha2/condition.proto 3 // DO NOT EDIT!!! 4 5 package condition 6 7 import ( 8 "encoding/json" 9 "strings" 10 11 "google.golang.org/grpc/codes" 12 "google.golang.org/grpc/status" 13 "google.golang.org/protobuf/proto" 14 preflect "google.golang.org/protobuf/reflect/protoreflect" 15 googlefieldmaskpb "google.golang.org/protobuf/types/known/fieldmaskpb" 16 17 gotenobject "github.com/cloudwan/goten-sdk/runtime/object" 18 ) 19 20 // proto imports 21 import ( 22 organization "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/organization" 23 project "github.com/cloudwan/edgelq-sdk/iam/resources/v1alpha2/project" 24 meta "github.com/cloudwan/goten-sdk/types/meta" 25 structpb "google.golang.org/protobuf/types/known/structpb" 26 ) 27 28 // ensure the imports are used 29 var ( 30 _ = new(json.Marshaler) 31 _ = strings.Builder{} 32 33 _ = codes.NotFound 34 _ = status.Status{} 35 _ = new(proto.Message) 36 _ = new(preflect.Message) 37 _ = googlefieldmaskpb.FieldMask{} 38 39 _ = new(gotenobject.FieldMask) 40 ) 41 42 // make sure we're using proto imports 43 var ( 44 _ = &organization.Organization{} 45 _ = &project.Project{} 46 _ = &structpb.Struct{} 47 _ = &meta.Meta{} 48 ) 49 50 type Condition_FieldMask struct { 51 Paths []Condition_FieldPath 52 } 53 54 func FullCondition_FieldMask() *Condition_FieldMask { 55 res := &Condition_FieldMask{} 56 res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorName}) 57 res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorDisplayName}) 58 res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorDescription}) 59 res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorExpression}) 60 res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorParameterDeclarations}) 61 res.Paths = append(res.Paths, &Condition_FieldTerminalPath{selector: Condition_FieldPathSelectorMetadata}) 62 return res 63 } 64 65 func (fieldMask *Condition_FieldMask) String() string { 66 if fieldMask == nil { 67 return "<nil>" 68 } 69 pathsStr := make([]string, 0, len(fieldMask.Paths)) 70 for _, path := range fieldMask.Paths { 71 pathsStr = append(pathsStr, path.String()) 72 } 73 return strings.Join(pathsStr, ", ") 74 } 75 76 func (fieldMask *Condition_FieldMask) IsFull() bool { 77 if fieldMask == nil { 78 return false 79 } 80 presentSelectors := make([]bool, 6) 81 for _, path := range fieldMask.Paths { 82 if asFinal, ok := path.(*Condition_FieldTerminalPath); ok { 83 presentSelectors[int(asFinal.selector)] = true 84 } 85 } 86 for _, flag := range presentSelectors { 87 if !flag { 88 return false 89 } 90 } 91 return true 92 } 93 94 func (fieldMask *Condition_FieldMask) ProtoReflect() preflect.Message { 95 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 96 return ParseCondition_FieldPath(raw) 97 }) 98 } 99 100 func (fieldMask *Condition_FieldMask) ProtoMessage() {} 101 102 func (fieldMask *Condition_FieldMask) Reset() { 103 if fieldMask != nil { 104 fieldMask.Paths = nil 105 } 106 } 107 108 func (fieldMask *Condition_FieldMask) Subtract(other *Condition_FieldMask) *Condition_FieldMask { 109 result := &Condition_FieldMask{} 110 removedSelectors := make([]bool, 6) 111 otherSubMasks := map[Condition_FieldPathSelector]gotenobject.FieldMask{ 112 Condition_FieldPathSelectorParameterDeclarations: &Condition_ParameterDeclaration_FieldMask{}, 113 Condition_FieldPathSelectorMetadata: &meta.Meta_FieldMask{}, 114 } 115 mySubMasks := map[Condition_FieldPathSelector]gotenobject.FieldMask{ 116 Condition_FieldPathSelectorParameterDeclarations: &Condition_ParameterDeclaration_FieldMask{}, 117 Condition_FieldPathSelectorMetadata: &meta.Meta_FieldMask{}, 118 } 119 120 for _, path := range other.GetPaths() { 121 switch tp := path.(type) { 122 case *Condition_FieldTerminalPath: 123 removedSelectors[int(tp.selector)] = true 124 case *Condition_FieldSubPath: 125 otherSubMasks[tp.selector].AppendRawPath(tp.subPath) 126 } 127 } 128 for _, path := range fieldMask.GetPaths() { 129 if !removedSelectors[int(path.Selector())] { 130 if otherSubMask := otherSubMasks[path.Selector()]; otherSubMask != nil && otherSubMask.PathsCount() > 0 { 131 if tp, ok := path.(*Condition_FieldTerminalPath); ok { 132 switch tp.selector { 133 case Condition_FieldPathSelectorParameterDeclarations: 134 mySubMasks[Condition_FieldPathSelectorParameterDeclarations] = FullCondition_ParameterDeclaration_FieldMask() 135 case Condition_FieldPathSelectorMetadata: 136 mySubMasks[Condition_FieldPathSelectorMetadata] = meta.FullMeta_FieldMask() 137 } 138 } else if tp, ok := path.(*Condition_FieldSubPath); ok { 139 mySubMasks[tp.selector].AppendRawPath(tp.subPath) 140 } 141 } else { 142 result.Paths = append(result.Paths, path) 143 } 144 } 145 } 146 for selector, mySubMask := range mySubMasks { 147 if mySubMask.PathsCount() > 0 { 148 for _, allowedPath := range mySubMask.SubtractRaw(otherSubMasks[selector]).GetRawPaths() { 149 result.Paths = append(result.Paths, &Condition_FieldSubPath{selector: selector, subPath: allowedPath}) 150 } 151 } 152 } 153 154 if len(result.Paths) == 0 { 155 return nil 156 } 157 return result 158 } 159 160 func (fieldMask *Condition_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 161 return fieldMask.Subtract(other.(*Condition_FieldMask)) 162 } 163 164 // FilterInputFields generates copy of field paths with output_only field paths removed 165 func (fieldMask *Condition_FieldMask) FilterInputFields() *Condition_FieldMask { 166 result := &Condition_FieldMask{} 167 for _, path := range fieldMask.Paths { 168 switch path.Selector() { 169 case Condition_FieldPathSelectorMetadata: 170 if _, ok := path.(*Condition_FieldTerminalPath); ok { 171 for _, subpath := range meta.FullMeta_FieldMask().FilterInputFields().Paths { 172 result.Paths = append(result.Paths, &Condition_FieldSubPath{selector: path.Selector(), subPath: subpath}) 173 } 174 } else if sub, ok := path.(*Condition_FieldSubPath); ok { 175 selectedMask := &meta.Meta_FieldMask{ 176 Paths: []meta.Meta_FieldPath{sub.subPath.(meta.Meta_FieldPath)}, 177 } 178 for _, allowedPath := range selectedMask.FilterInputFields().Paths { 179 result.Paths = append(result.Paths, &Condition_FieldSubPath{selector: Condition_FieldPathSelectorMetadata, subPath: allowedPath}) 180 } 181 } 182 default: 183 result.Paths = append(result.Paths, path) 184 } 185 } 186 return result 187 } 188 189 // ToFieldMask is used for proto conversions 190 func (fieldMask *Condition_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 191 protoFieldMask := &googlefieldmaskpb.FieldMask{} 192 for _, path := range fieldMask.Paths { 193 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 194 } 195 return protoFieldMask 196 } 197 198 func (fieldMask *Condition_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 199 if fieldMask == nil { 200 return status.Error(codes.Internal, "target field mask is nil") 201 } 202 fieldMask.Paths = make([]Condition_FieldPath, 0, len(protoFieldMask.Paths)) 203 for _, strPath := range protoFieldMask.Paths { 204 path, err := ParseCondition_FieldPath(strPath) 205 if err != nil { 206 return err 207 } 208 fieldMask.Paths = append(fieldMask.Paths, path) 209 } 210 return nil 211 } 212 213 // implement methods required by customType 214 func (fieldMask Condition_FieldMask) Marshal() ([]byte, error) { 215 protoFieldMask := fieldMask.ToProtoFieldMask() 216 return proto.Marshal(protoFieldMask) 217 } 218 219 func (fieldMask *Condition_FieldMask) Unmarshal(data []byte) error { 220 protoFieldMask := &googlefieldmaskpb.FieldMask{} 221 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 222 return err 223 } 224 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 225 return err 226 } 227 return nil 228 } 229 230 func (fieldMask *Condition_FieldMask) Size() int { 231 return proto.Size(fieldMask.ToProtoFieldMask()) 232 } 233 234 func (fieldMask Condition_FieldMask) MarshalJSON() ([]byte, error) { 235 return json.Marshal(fieldMask.ToProtoFieldMask()) 236 } 237 238 func (fieldMask *Condition_FieldMask) UnmarshalJSON(data []byte) error { 239 protoFieldMask := &googlefieldmaskpb.FieldMask{} 240 if err := json.Unmarshal(data, protoFieldMask); err != nil { 241 return err 242 } 243 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 244 return err 245 } 246 return nil 247 } 248 249 func (fieldMask *Condition_FieldMask) AppendPath(path Condition_FieldPath) { 250 fieldMask.Paths = append(fieldMask.Paths, path) 251 } 252 253 func (fieldMask *Condition_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 254 fieldMask.Paths = append(fieldMask.Paths, path.(Condition_FieldPath)) 255 } 256 257 func (fieldMask *Condition_FieldMask) GetPaths() []Condition_FieldPath { 258 if fieldMask == nil { 259 return nil 260 } 261 return fieldMask.Paths 262 } 263 264 func (fieldMask *Condition_FieldMask) GetRawPaths() []gotenobject.FieldPath { 265 if fieldMask == nil { 266 return nil 267 } 268 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 269 for _, path := range fieldMask.Paths { 270 rawPaths = append(rawPaths, path) 271 } 272 return rawPaths 273 } 274 275 func (fieldMask *Condition_FieldMask) SetFromCliFlag(raw string) error { 276 path, err := ParseCondition_FieldPath(raw) 277 if err != nil { 278 return err 279 } 280 fieldMask.Paths = append(fieldMask.Paths, path) 281 return nil 282 } 283 284 func (fieldMask *Condition_FieldMask) Set(target, source *Condition) { 285 for _, path := range fieldMask.Paths { 286 val, _ := path.GetSingle(source) 287 // if val is nil, then field does not exist in source, skip 288 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 289 if val != nil { 290 path.WithIValue(val).SetTo(&target) 291 } 292 } 293 } 294 295 func (fieldMask *Condition_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 296 fieldMask.Set(target.(*Condition), source.(*Condition)) 297 } 298 299 func (fieldMask *Condition_FieldMask) Project(source *Condition) *Condition { 300 if source == nil { 301 return nil 302 } 303 if fieldMask == nil { 304 return source 305 } 306 result := &Condition{} 307 parameterDeclarationsMask := &Condition_ParameterDeclaration_FieldMask{} 308 wholeParameterDeclarationsAccepted := false 309 metadataMask := &meta.Meta_FieldMask{} 310 wholeMetadataAccepted := false 311 312 for _, p := range fieldMask.Paths { 313 switch tp := p.(type) { 314 case *Condition_FieldTerminalPath: 315 switch tp.selector { 316 case Condition_FieldPathSelectorName: 317 result.Name = source.Name 318 case Condition_FieldPathSelectorDisplayName: 319 result.DisplayName = source.DisplayName 320 case Condition_FieldPathSelectorDescription: 321 result.Description = source.Description 322 case Condition_FieldPathSelectorExpression: 323 result.Expression = source.Expression 324 case Condition_FieldPathSelectorParameterDeclarations: 325 result.ParameterDeclarations = source.ParameterDeclarations 326 wholeParameterDeclarationsAccepted = true 327 case Condition_FieldPathSelectorMetadata: 328 result.Metadata = source.Metadata 329 wholeMetadataAccepted = true 330 } 331 case *Condition_FieldSubPath: 332 switch tp.selector { 333 case Condition_FieldPathSelectorParameterDeclarations: 334 parameterDeclarationsMask.AppendPath(tp.subPath.(ConditionParameterDeclaration_FieldPath)) 335 case Condition_FieldPathSelectorMetadata: 336 metadataMask.AppendPath(tp.subPath.(meta.Meta_FieldPath)) 337 } 338 } 339 } 340 if wholeParameterDeclarationsAccepted == false && len(parameterDeclarationsMask.Paths) > 0 { 341 for _, sourceItem := range source.GetParameterDeclarations() { 342 result.ParameterDeclarations = append(result.ParameterDeclarations, parameterDeclarationsMask.Project(sourceItem)) 343 } 344 } 345 if wholeMetadataAccepted == false && len(metadataMask.Paths) > 0 { 346 result.Metadata = metadataMask.Project(source.GetMetadata()) 347 } 348 return result 349 } 350 351 func (fieldMask *Condition_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 352 return fieldMask.Project(source.(*Condition)) 353 } 354 355 func (fieldMask *Condition_FieldMask) PathsCount() int { 356 if fieldMask == nil { 357 return 0 358 } 359 return len(fieldMask.Paths) 360 } 361 362 type Condition_ParameterDeclaration_FieldMask struct { 363 Paths []ConditionParameterDeclaration_FieldPath 364 } 365 366 func FullCondition_ParameterDeclaration_FieldMask() *Condition_ParameterDeclaration_FieldMask { 367 res := &Condition_ParameterDeclaration_FieldMask{} 368 res.Paths = append(res.Paths, &ConditionParameterDeclaration_FieldTerminalPath{selector: ConditionParameterDeclaration_FieldPathSelectorKey}) 369 res.Paths = append(res.Paths, &ConditionParameterDeclaration_FieldTerminalPath{selector: ConditionParameterDeclaration_FieldPathSelectorType}) 370 return res 371 } 372 373 func (fieldMask *Condition_ParameterDeclaration_FieldMask) String() string { 374 if fieldMask == nil { 375 return "<nil>" 376 } 377 pathsStr := make([]string, 0, len(fieldMask.Paths)) 378 for _, path := range fieldMask.Paths { 379 pathsStr = append(pathsStr, path.String()) 380 } 381 return strings.Join(pathsStr, ", ") 382 } 383 384 func (fieldMask *Condition_ParameterDeclaration_FieldMask) IsFull() bool { 385 if fieldMask == nil { 386 return false 387 } 388 presentSelectors := make([]bool, 2) 389 for _, path := range fieldMask.Paths { 390 if asFinal, ok := path.(*ConditionParameterDeclaration_FieldTerminalPath); ok { 391 presentSelectors[int(asFinal.selector)] = true 392 } 393 } 394 for _, flag := range presentSelectors { 395 if !flag { 396 return false 397 } 398 } 399 return true 400 } 401 402 func (fieldMask *Condition_ParameterDeclaration_FieldMask) ProtoReflect() preflect.Message { 403 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 404 return ParseConditionParameterDeclaration_FieldPath(raw) 405 }) 406 } 407 408 func (fieldMask *Condition_ParameterDeclaration_FieldMask) ProtoMessage() {} 409 410 func (fieldMask *Condition_ParameterDeclaration_FieldMask) Reset() { 411 if fieldMask != nil { 412 fieldMask.Paths = nil 413 } 414 } 415 416 func (fieldMask *Condition_ParameterDeclaration_FieldMask) Subtract(other *Condition_ParameterDeclaration_FieldMask) *Condition_ParameterDeclaration_FieldMask { 417 result := &Condition_ParameterDeclaration_FieldMask{} 418 removedSelectors := make([]bool, 2) 419 420 for _, path := range other.GetPaths() { 421 switch tp := path.(type) { 422 case *ConditionParameterDeclaration_FieldTerminalPath: 423 removedSelectors[int(tp.selector)] = true 424 } 425 } 426 for _, path := range fieldMask.GetPaths() { 427 if !removedSelectors[int(path.Selector())] { 428 result.Paths = append(result.Paths, path) 429 } 430 } 431 432 if len(result.Paths) == 0 { 433 return nil 434 } 435 return result 436 } 437 438 func (fieldMask *Condition_ParameterDeclaration_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 439 return fieldMask.Subtract(other.(*Condition_ParameterDeclaration_FieldMask)) 440 } 441 442 // FilterInputFields generates copy of field paths with output_only field paths removed 443 func (fieldMask *Condition_ParameterDeclaration_FieldMask) FilterInputFields() *Condition_ParameterDeclaration_FieldMask { 444 result := &Condition_ParameterDeclaration_FieldMask{} 445 result.Paths = append(result.Paths, fieldMask.Paths...) 446 return result 447 } 448 449 // ToFieldMask is used for proto conversions 450 func (fieldMask *Condition_ParameterDeclaration_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 451 protoFieldMask := &googlefieldmaskpb.FieldMask{} 452 for _, path := range fieldMask.Paths { 453 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 454 } 455 return protoFieldMask 456 } 457 458 func (fieldMask *Condition_ParameterDeclaration_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 459 if fieldMask == nil { 460 return status.Error(codes.Internal, "target field mask is nil") 461 } 462 fieldMask.Paths = make([]ConditionParameterDeclaration_FieldPath, 0, len(protoFieldMask.Paths)) 463 for _, strPath := range protoFieldMask.Paths { 464 path, err := ParseConditionParameterDeclaration_FieldPath(strPath) 465 if err != nil { 466 return err 467 } 468 fieldMask.Paths = append(fieldMask.Paths, path) 469 } 470 return nil 471 } 472 473 // implement methods required by customType 474 func (fieldMask Condition_ParameterDeclaration_FieldMask) Marshal() ([]byte, error) { 475 protoFieldMask := fieldMask.ToProtoFieldMask() 476 return proto.Marshal(protoFieldMask) 477 } 478 479 func (fieldMask *Condition_ParameterDeclaration_FieldMask) Unmarshal(data []byte) error { 480 protoFieldMask := &googlefieldmaskpb.FieldMask{} 481 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 482 return err 483 } 484 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 485 return err 486 } 487 return nil 488 } 489 490 func (fieldMask *Condition_ParameterDeclaration_FieldMask) Size() int { 491 return proto.Size(fieldMask.ToProtoFieldMask()) 492 } 493 494 func (fieldMask Condition_ParameterDeclaration_FieldMask) MarshalJSON() ([]byte, error) { 495 return json.Marshal(fieldMask.ToProtoFieldMask()) 496 } 497 498 func (fieldMask *Condition_ParameterDeclaration_FieldMask) UnmarshalJSON(data []byte) error { 499 protoFieldMask := &googlefieldmaskpb.FieldMask{} 500 if err := json.Unmarshal(data, protoFieldMask); err != nil { 501 return err 502 } 503 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 504 return err 505 } 506 return nil 507 } 508 509 func (fieldMask *Condition_ParameterDeclaration_FieldMask) AppendPath(path ConditionParameterDeclaration_FieldPath) { 510 fieldMask.Paths = append(fieldMask.Paths, path) 511 } 512 513 func (fieldMask *Condition_ParameterDeclaration_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 514 fieldMask.Paths = append(fieldMask.Paths, path.(ConditionParameterDeclaration_FieldPath)) 515 } 516 517 func (fieldMask *Condition_ParameterDeclaration_FieldMask) GetPaths() []ConditionParameterDeclaration_FieldPath { 518 if fieldMask == nil { 519 return nil 520 } 521 return fieldMask.Paths 522 } 523 524 func (fieldMask *Condition_ParameterDeclaration_FieldMask) GetRawPaths() []gotenobject.FieldPath { 525 if fieldMask == nil { 526 return nil 527 } 528 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 529 for _, path := range fieldMask.Paths { 530 rawPaths = append(rawPaths, path) 531 } 532 return rawPaths 533 } 534 535 func (fieldMask *Condition_ParameterDeclaration_FieldMask) SetFromCliFlag(raw string) error { 536 path, err := ParseConditionParameterDeclaration_FieldPath(raw) 537 if err != nil { 538 return err 539 } 540 fieldMask.Paths = append(fieldMask.Paths, path) 541 return nil 542 } 543 544 func (fieldMask *Condition_ParameterDeclaration_FieldMask) Set(target, source *Condition_ParameterDeclaration) { 545 for _, path := range fieldMask.Paths { 546 val, _ := path.GetSingle(source) 547 // if val is nil, then field does not exist in source, skip 548 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 549 if val != nil { 550 path.WithIValue(val).SetTo(&target) 551 } 552 } 553 } 554 555 func (fieldMask *Condition_ParameterDeclaration_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 556 fieldMask.Set(target.(*Condition_ParameterDeclaration), source.(*Condition_ParameterDeclaration)) 557 } 558 559 func (fieldMask *Condition_ParameterDeclaration_FieldMask) Project(source *Condition_ParameterDeclaration) *Condition_ParameterDeclaration { 560 if source == nil { 561 return nil 562 } 563 if fieldMask == nil { 564 return source 565 } 566 result := &Condition_ParameterDeclaration{} 567 568 for _, p := range fieldMask.Paths { 569 switch tp := p.(type) { 570 case *ConditionParameterDeclaration_FieldTerminalPath: 571 switch tp.selector { 572 case ConditionParameterDeclaration_FieldPathSelectorKey: 573 result.Key = source.Key 574 case ConditionParameterDeclaration_FieldPathSelectorType: 575 result.Type = source.Type 576 } 577 } 578 } 579 return result 580 } 581 582 func (fieldMask *Condition_ParameterDeclaration_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 583 return fieldMask.Project(source.(*Condition_ParameterDeclaration)) 584 } 585 586 func (fieldMask *Condition_ParameterDeclaration_FieldMask) PathsCount() int { 587 if fieldMask == nil { 588 return 0 589 } 590 return len(fieldMask.Paths) 591 } 592 593 type ConditionBinding_FieldMask struct { 594 Paths []ConditionBinding_FieldPath 595 } 596 597 func FullConditionBinding_FieldMask() *ConditionBinding_FieldMask { 598 res := &ConditionBinding_FieldMask{} 599 res.Paths = append(res.Paths, &ConditionBinding_FieldTerminalPath{selector: ConditionBinding_FieldPathSelectorCondition}) 600 res.Paths = append(res.Paths, &ConditionBinding_FieldTerminalPath{selector: ConditionBinding_FieldPathSelectorParameters}) 601 res.Paths = append(res.Paths, &ConditionBinding_FieldTerminalPath{selector: ConditionBinding_FieldPathSelectorParams}) 602 return res 603 } 604 605 func (fieldMask *ConditionBinding_FieldMask) String() string { 606 if fieldMask == nil { 607 return "<nil>" 608 } 609 pathsStr := make([]string, 0, len(fieldMask.Paths)) 610 for _, path := range fieldMask.Paths { 611 pathsStr = append(pathsStr, path.String()) 612 } 613 return strings.Join(pathsStr, ", ") 614 } 615 616 func (fieldMask *ConditionBinding_FieldMask) IsFull() bool { 617 if fieldMask == nil { 618 return false 619 } 620 presentSelectors := make([]bool, 3) 621 for _, path := range fieldMask.Paths { 622 if asFinal, ok := path.(*ConditionBinding_FieldTerminalPath); ok { 623 presentSelectors[int(asFinal.selector)] = true 624 } 625 } 626 for _, flag := range presentSelectors { 627 if !flag { 628 return false 629 } 630 } 631 return true 632 } 633 634 func (fieldMask *ConditionBinding_FieldMask) ProtoReflect() preflect.Message { 635 return gotenobject.MakeFieldMaskReflection(fieldMask, func(raw string) (gotenobject.FieldPath, error) { 636 return ParseConditionBinding_FieldPath(raw) 637 }) 638 } 639 640 func (fieldMask *ConditionBinding_FieldMask) ProtoMessage() {} 641 642 func (fieldMask *ConditionBinding_FieldMask) Reset() { 643 if fieldMask != nil { 644 fieldMask.Paths = nil 645 } 646 } 647 648 func (fieldMask *ConditionBinding_FieldMask) Subtract(other *ConditionBinding_FieldMask) *ConditionBinding_FieldMask { 649 result := &ConditionBinding_FieldMask{} 650 removedSelectors := make([]bool, 3) 651 652 for _, path := range other.GetPaths() { 653 switch tp := path.(type) { 654 case *ConditionBinding_FieldTerminalPath: 655 removedSelectors[int(tp.selector)] = true 656 } 657 } 658 for _, path := range fieldMask.GetPaths() { 659 if !removedSelectors[int(path.Selector())] { 660 result.Paths = append(result.Paths, path) 661 } 662 } 663 664 if len(result.Paths) == 0 { 665 return nil 666 } 667 return result 668 } 669 670 func (fieldMask *ConditionBinding_FieldMask) SubtractRaw(other gotenobject.FieldMask) gotenobject.FieldMask { 671 return fieldMask.Subtract(other.(*ConditionBinding_FieldMask)) 672 } 673 674 // FilterInputFields generates copy of field paths with output_only field paths removed 675 func (fieldMask *ConditionBinding_FieldMask) FilterInputFields() *ConditionBinding_FieldMask { 676 result := &ConditionBinding_FieldMask{} 677 result.Paths = append(result.Paths, fieldMask.Paths...) 678 return result 679 } 680 681 // ToFieldMask is used for proto conversions 682 func (fieldMask *ConditionBinding_FieldMask) ToProtoFieldMask() *googlefieldmaskpb.FieldMask { 683 protoFieldMask := &googlefieldmaskpb.FieldMask{} 684 for _, path := range fieldMask.Paths { 685 protoFieldMask.Paths = append(protoFieldMask.Paths, path.String()) 686 } 687 return protoFieldMask 688 } 689 690 func (fieldMask *ConditionBinding_FieldMask) FromProtoFieldMask(protoFieldMask *googlefieldmaskpb.FieldMask) error { 691 if fieldMask == nil { 692 return status.Error(codes.Internal, "target field mask is nil") 693 } 694 fieldMask.Paths = make([]ConditionBinding_FieldPath, 0, len(protoFieldMask.Paths)) 695 for _, strPath := range protoFieldMask.Paths { 696 path, err := ParseConditionBinding_FieldPath(strPath) 697 if err != nil { 698 return err 699 } 700 fieldMask.Paths = append(fieldMask.Paths, path) 701 } 702 return nil 703 } 704 705 // implement methods required by customType 706 func (fieldMask ConditionBinding_FieldMask) Marshal() ([]byte, error) { 707 protoFieldMask := fieldMask.ToProtoFieldMask() 708 return proto.Marshal(protoFieldMask) 709 } 710 711 func (fieldMask *ConditionBinding_FieldMask) Unmarshal(data []byte) error { 712 protoFieldMask := &googlefieldmaskpb.FieldMask{} 713 if err := proto.Unmarshal(data, protoFieldMask); err != nil { 714 return err 715 } 716 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 717 return err 718 } 719 return nil 720 } 721 722 func (fieldMask *ConditionBinding_FieldMask) Size() int { 723 return proto.Size(fieldMask.ToProtoFieldMask()) 724 } 725 726 func (fieldMask ConditionBinding_FieldMask) MarshalJSON() ([]byte, error) { 727 return json.Marshal(fieldMask.ToProtoFieldMask()) 728 } 729 730 func (fieldMask *ConditionBinding_FieldMask) UnmarshalJSON(data []byte) error { 731 protoFieldMask := &googlefieldmaskpb.FieldMask{} 732 if err := json.Unmarshal(data, protoFieldMask); err != nil { 733 return err 734 } 735 if err := fieldMask.FromProtoFieldMask(protoFieldMask); err != nil { 736 return err 737 } 738 return nil 739 } 740 741 func (fieldMask *ConditionBinding_FieldMask) AppendPath(path ConditionBinding_FieldPath) { 742 fieldMask.Paths = append(fieldMask.Paths, path) 743 } 744 745 func (fieldMask *ConditionBinding_FieldMask) AppendRawPath(path gotenobject.FieldPath) { 746 fieldMask.Paths = append(fieldMask.Paths, path.(ConditionBinding_FieldPath)) 747 } 748 749 func (fieldMask *ConditionBinding_FieldMask) GetPaths() []ConditionBinding_FieldPath { 750 if fieldMask == nil { 751 return nil 752 } 753 return fieldMask.Paths 754 } 755 756 func (fieldMask *ConditionBinding_FieldMask) GetRawPaths() []gotenobject.FieldPath { 757 if fieldMask == nil { 758 return nil 759 } 760 rawPaths := make([]gotenobject.FieldPath, 0, len(fieldMask.Paths)) 761 for _, path := range fieldMask.Paths { 762 rawPaths = append(rawPaths, path) 763 } 764 return rawPaths 765 } 766 767 func (fieldMask *ConditionBinding_FieldMask) SetFromCliFlag(raw string) error { 768 path, err := ParseConditionBinding_FieldPath(raw) 769 if err != nil { 770 return err 771 } 772 fieldMask.Paths = append(fieldMask.Paths, path) 773 return nil 774 } 775 776 func (fieldMask *ConditionBinding_FieldMask) Set(target, source *ConditionBinding) { 777 for _, path := range fieldMask.Paths { 778 val, _ := path.GetSingle(source) 779 // if val is nil, then field does not exist in source, skip 780 // otherwise, process (can still reflect.ValueOf(val).IsNil!) 781 if val != nil { 782 path.WithIValue(val).SetTo(&target) 783 } 784 } 785 } 786 787 func (fieldMask *ConditionBinding_FieldMask) SetRaw(target, source gotenobject.GotenObjectExt) { 788 fieldMask.Set(target.(*ConditionBinding), source.(*ConditionBinding)) 789 } 790 791 func (fieldMask *ConditionBinding_FieldMask) Project(source *ConditionBinding) *ConditionBinding { 792 if source == nil { 793 return nil 794 } 795 if fieldMask == nil { 796 return source 797 } 798 result := &ConditionBinding{} 799 var parametersMapKeys []string 800 wholeParametersAccepted := false 801 802 for _, p := range fieldMask.Paths { 803 switch tp := p.(type) { 804 case *ConditionBinding_FieldTerminalPath: 805 switch tp.selector { 806 case ConditionBinding_FieldPathSelectorCondition: 807 result.Condition = source.Condition 808 case ConditionBinding_FieldPathSelectorParameters: 809 result.Parameters = source.Parameters 810 wholeParametersAccepted = true 811 case ConditionBinding_FieldPathSelectorParams: 812 result.Params = source.Params 813 } 814 case *ConditionBinding_FieldPathMap: 815 switch tp.selector { 816 case ConditionBinding_FieldPathSelectorParameters: 817 parametersMapKeys = append(parametersMapKeys, tp.key) 818 } 819 } 820 } 821 if wholeParametersAccepted == false && len(parametersMapKeys) > 0 && source.GetParameters() != nil { 822 copiedMap := map[string]string{} 823 sourceMap := source.GetParameters() 824 for _, key := range parametersMapKeys { 825 copiedMap[key] = sourceMap[key] 826 } 827 result.Parameters = copiedMap 828 } 829 return result 830 } 831 832 func (fieldMask *ConditionBinding_FieldMask) ProjectRaw(source gotenobject.GotenObjectExt) gotenobject.GotenObjectExt { 833 return fieldMask.Project(source.(*ConditionBinding)) 834 } 835 836 func (fieldMask *ConditionBinding_FieldMask) PathsCount() int { 837 if fieldMask == nil { 838 return 0 839 } 840 return len(fieldMask.Paths) 841 }