github.com/cloudwan/edgelq-sdk@v1.15.4/alerting/resources/v1/ts_condition_template/ts_condition_template.pb.fieldpath.go (about) 1 // Code generated by protoc-gen-goten-object 2 // File: edgelq/alerting/proto/v1/ts_condition_template.proto 3 // DO NOT EDIT!!! 4 5 package ts_condition_template 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 rcommon "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/common" 27 document "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/document" 28 policy_template "github.com/cloudwan/edgelq-sdk/alerting/resources/v1/policy_template" 29 meta "github.com/cloudwan/goten-sdk/types/meta" 30 ) 31 32 // ensure the imports are used 33 var ( 34 _ = new(json.Marshaler) 35 _ = new(fmt.Stringer) 36 _ = reflect.DeepEqual 37 _ = strings.Builder{} 38 _ = time.Second 39 40 _ = strcase.ToLowerCamel 41 _ = codes.NotFound 42 _ = status.Status{} 43 _ = protojson.UnmarshalOptions{} 44 _ = new(proto.Message) 45 _ = protoregistry.GlobalTypes 46 47 _ = new(gotenobject.FieldPath) 48 ) 49 50 // make sure we're using proto imports 51 var ( 52 _ = &document.Document{} 53 _ = &policy_template.PolicyTemplate{} 54 _ = &rcommon.LogCndSpec{} 55 _ = &meta.Meta{} 56 ) 57 58 // FieldPath provides implementation to handle 59 // https://github.com/protocolbuffers/protobuf/blob/master/src/google/protobuf/field_mask.proto 60 type TsConditionTemplate_FieldPath interface { 61 gotenobject.FieldPath 62 Selector() TsConditionTemplate_FieldPathSelector 63 Get(source *TsConditionTemplate) []interface{} 64 GetSingle(source *TsConditionTemplate) (interface{}, bool) 65 ClearValue(item *TsConditionTemplate) 66 67 // Those methods build corresponding TsConditionTemplate_FieldPathValue 68 // (or array of values) and holds passed value. Panics if injected type is incorrect. 69 WithIValue(value interface{}) TsConditionTemplate_FieldPathValue 70 WithIArrayOfValues(values interface{}) TsConditionTemplate_FieldPathArrayOfValues 71 WithIArrayItemValue(value interface{}) TsConditionTemplate_FieldPathArrayItemValue 72 } 73 74 type TsConditionTemplate_FieldPathSelector int32 75 76 const ( 77 TsConditionTemplate_FieldPathSelectorName TsConditionTemplate_FieldPathSelector = 0 78 TsConditionTemplate_FieldPathSelectorMetadata TsConditionTemplate_FieldPathSelector = 1 79 TsConditionTemplate_FieldPathSelectorDisplayName TsConditionTemplate_FieldPathSelector = 2 80 TsConditionTemplate_FieldPathSelectorDescription TsConditionTemplate_FieldPathSelector = 3 81 TsConditionTemplate_FieldPathSelectorSupportingDocs TsConditionTemplate_FieldPathSelector = 4 82 TsConditionTemplate_FieldPathSelectorSpecTemplate TsConditionTemplate_FieldPathSelector = 5 83 ) 84 85 func (s TsConditionTemplate_FieldPathSelector) String() string { 86 switch s { 87 case TsConditionTemplate_FieldPathSelectorName: 88 return "name" 89 case TsConditionTemplate_FieldPathSelectorMetadata: 90 return "metadata" 91 case TsConditionTemplate_FieldPathSelectorDisplayName: 92 return "display_name" 93 case TsConditionTemplate_FieldPathSelectorDescription: 94 return "description" 95 case TsConditionTemplate_FieldPathSelectorSupportingDocs: 96 return "supporting_docs" 97 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 98 return "spec_template" 99 default: 100 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", s)) 101 } 102 } 103 104 func BuildTsConditionTemplate_FieldPath(fp gotenobject.RawFieldPath) (TsConditionTemplate_FieldPath, error) { 105 if len(fp) == 0 { 106 return nil, status.Error(codes.InvalidArgument, "empty field path for object TsConditionTemplate") 107 } 108 if len(fp) == 1 { 109 switch fp[0] { 110 case "name": 111 return &TsConditionTemplate_FieldTerminalPath{selector: TsConditionTemplate_FieldPathSelectorName}, nil 112 case "metadata": 113 return &TsConditionTemplate_FieldTerminalPath{selector: TsConditionTemplate_FieldPathSelectorMetadata}, nil 114 case "display_name", "displayName", "display-name": 115 return &TsConditionTemplate_FieldTerminalPath{selector: TsConditionTemplate_FieldPathSelectorDisplayName}, nil 116 case "description": 117 return &TsConditionTemplate_FieldTerminalPath{selector: TsConditionTemplate_FieldPathSelectorDescription}, nil 118 case "supporting_docs", "supportingDocs", "supporting-docs": 119 return &TsConditionTemplate_FieldTerminalPath{selector: TsConditionTemplate_FieldPathSelectorSupportingDocs}, nil 120 case "spec_template", "specTemplate", "spec-template": 121 return &TsConditionTemplate_FieldTerminalPath{selector: TsConditionTemplate_FieldPathSelectorSpecTemplate}, nil 122 } 123 } else { 124 switch fp[0] { 125 case "metadata": 126 if subpath, err := meta.BuildMeta_FieldPath(fp[1:]); err != nil { 127 return nil, err 128 } else { 129 return &TsConditionTemplate_FieldSubPath{selector: TsConditionTemplate_FieldPathSelectorMetadata, subPath: subpath}, nil 130 } 131 case "spec_template", "specTemplate", "spec-template": 132 if subpath, err := rcommon.BuildTsCndSpec_FieldPath(fp[1:]); err != nil { 133 return nil, err 134 } else { 135 return &TsConditionTemplate_FieldSubPath{selector: TsConditionTemplate_FieldPathSelectorSpecTemplate, subPath: subpath}, nil 136 } 137 } 138 } 139 return nil, status.Errorf(codes.InvalidArgument, "unknown field path '%s' for object TsConditionTemplate", fp) 140 } 141 142 func ParseTsConditionTemplate_FieldPath(rawField string) (TsConditionTemplate_FieldPath, error) { 143 fp, err := gotenobject.ParseRawFieldPath(rawField) 144 if err != nil { 145 return nil, err 146 } 147 return BuildTsConditionTemplate_FieldPath(fp) 148 } 149 150 func MustParseTsConditionTemplate_FieldPath(rawField string) TsConditionTemplate_FieldPath { 151 fp, err := ParseTsConditionTemplate_FieldPath(rawField) 152 if err != nil { 153 panic(err) 154 } 155 return fp 156 } 157 158 type TsConditionTemplate_FieldTerminalPath struct { 159 selector TsConditionTemplate_FieldPathSelector 160 } 161 162 var _ TsConditionTemplate_FieldPath = (*TsConditionTemplate_FieldTerminalPath)(nil) 163 164 func (fp *TsConditionTemplate_FieldTerminalPath) Selector() TsConditionTemplate_FieldPathSelector { 165 return fp.selector 166 } 167 168 // String returns path representation in proto convention 169 func (fp *TsConditionTemplate_FieldTerminalPath) String() string { 170 return fp.selector.String() 171 } 172 173 // JSONString returns path representation is JSON convention 174 func (fp *TsConditionTemplate_FieldTerminalPath) JSONString() string { 175 return strcase.ToLowerCamel(fp.String()) 176 } 177 178 // Get returns all values pointed by specific field from source TsConditionTemplate 179 func (fp *TsConditionTemplate_FieldTerminalPath) Get(source *TsConditionTemplate) (values []interface{}) { 180 if source != nil { 181 switch fp.selector { 182 case TsConditionTemplate_FieldPathSelectorName: 183 if source.Name != nil { 184 values = append(values, source.Name) 185 } 186 case TsConditionTemplate_FieldPathSelectorMetadata: 187 if source.Metadata != nil { 188 values = append(values, source.Metadata) 189 } 190 case TsConditionTemplate_FieldPathSelectorDisplayName: 191 values = append(values, source.DisplayName) 192 case TsConditionTemplate_FieldPathSelectorDescription: 193 values = append(values, source.Description) 194 case TsConditionTemplate_FieldPathSelectorSupportingDocs: 195 for _, value := range source.GetSupportingDocs() { 196 values = append(values, value) 197 } 198 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 199 if source.SpecTemplate != nil { 200 values = append(values, source.SpecTemplate) 201 } 202 default: 203 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fp.selector)) 204 } 205 } 206 return 207 } 208 209 func (fp *TsConditionTemplate_FieldTerminalPath) GetRaw(source proto.Message) []interface{} { 210 return fp.Get(source.(*TsConditionTemplate)) 211 } 212 213 // GetSingle returns value pointed by specific field of from source TsConditionTemplate 214 func (fp *TsConditionTemplate_FieldTerminalPath) GetSingle(source *TsConditionTemplate) (interface{}, bool) { 215 switch fp.selector { 216 case TsConditionTemplate_FieldPathSelectorName: 217 res := source.GetName() 218 return res, res != nil 219 case TsConditionTemplate_FieldPathSelectorMetadata: 220 res := source.GetMetadata() 221 return res, res != nil 222 case TsConditionTemplate_FieldPathSelectorDisplayName: 223 return source.GetDisplayName(), source != nil 224 case TsConditionTemplate_FieldPathSelectorDescription: 225 return source.GetDescription(), source != nil 226 case TsConditionTemplate_FieldPathSelectorSupportingDocs: 227 res := source.GetSupportingDocs() 228 return res, res != nil 229 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 230 res := source.GetSpecTemplate() 231 return res, res != nil 232 default: 233 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fp.selector)) 234 } 235 } 236 237 func (fp *TsConditionTemplate_FieldTerminalPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 238 return fp.GetSingle(source.(*TsConditionTemplate)) 239 } 240 241 // GetDefault returns a default value of the field type 242 func (fp *TsConditionTemplate_FieldTerminalPath) GetDefault() interface{} { 243 switch fp.selector { 244 case TsConditionTemplate_FieldPathSelectorName: 245 return (*Name)(nil) 246 case TsConditionTemplate_FieldPathSelectorMetadata: 247 return (*meta.Meta)(nil) 248 case TsConditionTemplate_FieldPathSelectorDisplayName: 249 return "" 250 case TsConditionTemplate_FieldPathSelectorDescription: 251 return "" 252 case TsConditionTemplate_FieldPathSelectorSupportingDocs: 253 return ([]*document.Reference)(nil) 254 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 255 return (*rcommon.TsCndSpec)(nil) 256 default: 257 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fp.selector)) 258 } 259 } 260 261 func (fp *TsConditionTemplate_FieldTerminalPath) ClearValue(item *TsConditionTemplate) { 262 if item != nil { 263 switch fp.selector { 264 case TsConditionTemplate_FieldPathSelectorName: 265 item.Name = nil 266 case TsConditionTemplate_FieldPathSelectorMetadata: 267 item.Metadata = nil 268 case TsConditionTemplate_FieldPathSelectorDisplayName: 269 item.DisplayName = "" 270 case TsConditionTemplate_FieldPathSelectorDescription: 271 item.Description = "" 272 case TsConditionTemplate_FieldPathSelectorSupportingDocs: 273 item.SupportingDocs = nil 274 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 275 item.SpecTemplate = nil 276 default: 277 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fp.selector)) 278 } 279 } 280 } 281 282 func (fp *TsConditionTemplate_FieldTerminalPath) ClearValueRaw(item proto.Message) { 283 fp.ClearValue(item.(*TsConditionTemplate)) 284 } 285 286 // IsLeaf - whether field path is holds simple value 287 func (fp *TsConditionTemplate_FieldTerminalPath) IsLeaf() bool { 288 return fp.selector == TsConditionTemplate_FieldPathSelectorName || 289 fp.selector == TsConditionTemplate_FieldPathSelectorDisplayName || 290 fp.selector == TsConditionTemplate_FieldPathSelectorDescription || 291 fp.selector == TsConditionTemplate_FieldPathSelectorSupportingDocs 292 } 293 294 func (fp *TsConditionTemplate_FieldTerminalPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 295 return []gotenobject.FieldPath{fp} 296 } 297 298 func (fp *TsConditionTemplate_FieldTerminalPath) WithIValue(value interface{}) TsConditionTemplate_FieldPathValue { 299 switch fp.selector { 300 case TsConditionTemplate_FieldPathSelectorName: 301 return &TsConditionTemplate_FieldTerminalPathValue{TsConditionTemplate_FieldTerminalPath: *fp, value: value.(*Name)} 302 case TsConditionTemplate_FieldPathSelectorMetadata: 303 return &TsConditionTemplate_FieldTerminalPathValue{TsConditionTemplate_FieldTerminalPath: *fp, value: value.(*meta.Meta)} 304 case TsConditionTemplate_FieldPathSelectorDisplayName: 305 return &TsConditionTemplate_FieldTerminalPathValue{TsConditionTemplate_FieldTerminalPath: *fp, value: value.(string)} 306 case TsConditionTemplate_FieldPathSelectorDescription: 307 return &TsConditionTemplate_FieldTerminalPathValue{TsConditionTemplate_FieldTerminalPath: *fp, value: value.(string)} 308 case TsConditionTemplate_FieldPathSelectorSupportingDocs: 309 return &TsConditionTemplate_FieldTerminalPathValue{TsConditionTemplate_FieldTerminalPath: *fp, value: value.([]*document.Reference)} 310 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 311 return &TsConditionTemplate_FieldTerminalPathValue{TsConditionTemplate_FieldTerminalPath: *fp, value: value.(*rcommon.TsCndSpec)} 312 default: 313 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fp.selector)) 314 } 315 } 316 317 func (fp *TsConditionTemplate_FieldTerminalPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 318 return fp.WithIValue(value) 319 } 320 321 func (fp *TsConditionTemplate_FieldTerminalPath) WithIArrayOfValues(values interface{}) TsConditionTemplate_FieldPathArrayOfValues { 322 fpaov := &TsConditionTemplate_FieldTerminalPathArrayOfValues{TsConditionTemplate_FieldTerminalPath: *fp} 323 switch fp.selector { 324 case TsConditionTemplate_FieldPathSelectorName: 325 return &TsConditionTemplate_FieldTerminalPathArrayOfValues{TsConditionTemplate_FieldTerminalPath: *fp, values: values.([]*Name)} 326 case TsConditionTemplate_FieldPathSelectorMetadata: 327 return &TsConditionTemplate_FieldTerminalPathArrayOfValues{TsConditionTemplate_FieldTerminalPath: *fp, values: values.([]*meta.Meta)} 328 case TsConditionTemplate_FieldPathSelectorDisplayName: 329 return &TsConditionTemplate_FieldTerminalPathArrayOfValues{TsConditionTemplate_FieldTerminalPath: *fp, values: values.([]string)} 330 case TsConditionTemplate_FieldPathSelectorDescription: 331 return &TsConditionTemplate_FieldTerminalPathArrayOfValues{TsConditionTemplate_FieldTerminalPath: *fp, values: values.([]string)} 332 case TsConditionTemplate_FieldPathSelectorSupportingDocs: 333 return &TsConditionTemplate_FieldTerminalPathArrayOfValues{TsConditionTemplate_FieldTerminalPath: *fp, values: values.([][]*document.Reference)} 334 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 335 return &TsConditionTemplate_FieldTerminalPathArrayOfValues{TsConditionTemplate_FieldTerminalPath: *fp, values: values.([]*rcommon.TsCndSpec)} 336 default: 337 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fp.selector)) 338 } 339 return fpaov 340 } 341 342 func (fp *TsConditionTemplate_FieldTerminalPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 343 return fp.WithIArrayOfValues(values) 344 } 345 346 func (fp *TsConditionTemplate_FieldTerminalPath) WithIArrayItemValue(value interface{}) TsConditionTemplate_FieldPathArrayItemValue { 347 switch fp.selector { 348 case TsConditionTemplate_FieldPathSelectorSupportingDocs: 349 return &TsConditionTemplate_FieldTerminalPathArrayItemValue{TsConditionTemplate_FieldTerminalPath: *fp, value: value.(*document.Reference)} 350 default: 351 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fp.selector)) 352 } 353 } 354 355 func (fp *TsConditionTemplate_FieldTerminalPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 356 return fp.WithIArrayItemValue(value) 357 } 358 359 type TsConditionTemplate_FieldSubPath struct { 360 selector TsConditionTemplate_FieldPathSelector 361 subPath gotenobject.FieldPath 362 } 363 364 var _ TsConditionTemplate_FieldPath = (*TsConditionTemplate_FieldSubPath)(nil) 365 366 func (fps *TsConditionTemplate_FieldSubPath) Selector() TsConditionTemplate_FieldPathSelector { 367 return fps.selector 368 } 369 func (fps *TsConditionTemplate_FieldSubPath) AsMetadataSubPath() (meta.Meta_FieldPath, bool) { 370 res, ok := fps.subPath.(meta.Meta_FieldPath) 371 return res, ok 372 } 373 func (fps *TsConditionTemplate_FieldSubPath) AsSpecTemplateSubPath() (rcommon.TsCndSpec_FieldPath, bool) { 374 res, ok := fps.subPath.(rcommon.TsCndSpec_FieldPath) 375 return res, ok 376 } 377 378 // String returns path representation in proto convention 379 func (fps *TsConditionTemplate_FieldSubPath) String() string { 380 return fps.selector.String() + "." + fps.subPath.String() 381 } 382 383 // JSONString returns path representation is JSON convention 384 func (fps *TsConditionTemplate_FieldSubPath) JSONString() string { 385 return strcase.ToLowerCamel(fps.selector.String()) + "." + fps.subPath.JSONString() 386 } 387 388 // Get returns all values pointed by selected field from source TsConditionTemplate 389 func (fps *TsConditionTemplate_FieldSubPath) Get(source *TsConditionTemplate) (values []interface{}) { 390 switch fps.selector { 391 case TsConditionTemplate_FieldPathSelectorMetadata: 392 values = append(values, fps.subPath.GetRaw(source.GetMetadata())...) 393 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 394 values = append(values, fps.subPath.GetRaw(source.GetSpecTemplate())...) 395 default: 396 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fps.selector)) 397 } 398 return 399 } 400 401 func (fps *TsConditionTemplate_FieldSubPath) GetRaw(source proto.Message) []interface{} { 402 return fps.Get(source.(*TsConditionTemplate)) 403 } 404 405 // GetSingle returns value of selected field from source TsConditionTemplate 406 func (fps *TsConditionTemplate_FieldSubPath) GetSingle(source *TsConditionTemplate) (interface{}, bool) { 407 switch fps.selector { 408 case TsConditionTemplate_FieldPathSelectorMetadata: 409 if source.GetMetadata() == nil { 410 return nil, false 411 } 412 return fps.subPath.GetSingleRaw(source.GetMetadata()) 413 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 414 if source.GetSpecTemplate() == nil { 415 return nil, false 416 } 417 return fps.subPath.GetSingleRaw(source.GetSpecTemplate()) 418 default: 419 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fps.selector)) 420 } 421 } 422 423 func (fps *TsConditionTemplate_FieldSubPath) GetSingleRaw(source proto.Message) (interface{}, bool) { 424 return fps.GetSingle(source.(*TsConditionTemplate)) 425 } 426 427 // GetDefault returns a default value of the field type 428 func (fps *TsConditionTemplate_FieldSubPath) GetDefault() interface{} { 429 return fps.subPath.GetDefault() 430 } 431 432 func (fps *TsConditionTemplate_FieldSubPath) ClearValue(item *TsConditionTemplate) { 433 if item != nil { 434 switch fps.selector { 435 case TsConditionTemplate_FieldPathSelectorMetadata: 436 fps.subPath.ClearValueRaw(item.Metadata) 437 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 438 fps.subPath.ClearValueRaw(item.SpecTemplate) 439 default: 440 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fps.selector)) 441 } 442 } 443 } 444 445 func (fps *TsConditionTemplate_FieldSubPath) ClearValueRaw(item proto.Message) { 446 fps.ClearValue(item.(*TsConditionTemplate)) 447 } 448 449 // IsLeaf - whether field path is holds simple value 450 func (fps *TsConditionTemplate_FieldSubPath) IsLeaf() bool { 451 return fps.subPath.IsLeaf() 452 } 453 454 func (fps *TsConditionTemplate_FieldSubPath) SplitIntoTerminalIPaths() []gotenobject.FieldPath { 455 iPaths := []gotenobject.FieldPath{&TsConditionTemplate_FieldTerminalPath{selector: fps.selector}} 456 iPaths = append(iPaths, fps.subPath.SplitIntoTerminalIPaths()...) 457 return iPaths 458 } 459 460 func (fps *TsConditionTemplate_FieldSubPath) WithIValue(value interface{}) TsConditionTemplate_FieldPathValue { 461 return &TsConditionTemplate_FieldSubPathValue{fps, fps.subPath.WithRawIValue(value)} 462 } 463 464 func (fps *TsConditionTemplate_FieldSubPath) WithRawIValue(value interface{}) gotenobject.FieldPathValue { 465 return fps.WithIValue(value) 466 } 467 468 func (fps *TsConditionTemplate_FieldSubPath) WithIArrayOfValues(values interface{}) TsConditionTemplate_FieldPathArrayOfValues { 469 return &TsConditionTemplate_FieldSubPathArrayOfValues{fps, fps.subPath.WithRawIArrayOfValues(values)} 470 } 471 472 func (fps *TsConditionTemplate_FieldSubPath) WithRawIArrayOfValues(values interface{}) gotenobject.FieldPathArrayOfValues { 473 return fps.WithIArrayOfValues(values) 474 } 475 476 func (fps *TsConditionTemplate_FieldSubPath) WithIArrayItemValue(value interface{}) TsConditionTemplate_FieldPathArrayItemValue { 477 return &TsConditionTemplate_FieldSubPathArrayItemValue{fps, fps.subPath.WithRawIArrayItemValue(value)} 478 } 479 480 func (fps *TsConditionTemplate_FieldSubPath) WithRawIArrayItemValue(value interface{}) gotenobject.FieldPathArrayItemValue { 481 return fps.WithIArrayItemValue(value) 482 } 483 484 // TsConditionTemplate_FieldPathValue allows storing values for TsConditionTemplate fields according to their type 485 type TsConditionTemplate_FieldPathValue interface { 486 TsConditionTemplate_FieldPath 487 gotenobject.FieldPathValue 488 SetTo(target **TsConditionTemplate) 489 CompareWith(*TsConditionTemplate) (cmp int, comparable bool) 490 } 491 492 func ParseTsConditionTemplate_FieldPathValue(pathStr, valueStr string) (TsConditionTemplate_FieldPathValue, error) { 493 fp, err := ParseTsConditionTemplate_FieldPath(pathStr) 494 if err != nil { 495 return nil, err 496 } 497 fpv, err := gotenobject.ParseFieldPathValue(fp, valueStr) 498 if err != nil { 499 return nil, status.Errorf(codes.InvalidArgument, "error parsing TsConditionTemplate field path value from %s: %v", valueStr, err) 500 } 501 return fpv.(TsConditionTemplate_FieldPathValue), nil 502 } 503 504 func MustParseTsConditionTemplate_FieldPathValue(pathStr, valueStr string) TsConditionTemplate_FieldPathValue { 505 fpv, err := ParseTsConditionTemplate_FieldPathValue(pathStr, valueStr) 506 if err != nil { 507 panic(err) 508 } 509 return fpv 510 } 511 512 type TsConditionTemplate_FieldTerminalPathValue struct { 513 TsConditionTemplate_FieldTerminalPath 514 value interface{} 515 } 516 517 var _ TsConditionTemplate_FieldPathValue = (*TsConditionTemplate_FieldTerminalPathValue)(nil) 518 519 // GetRawValue returns raw value stored under selected path for 'TsConditionTemplate' as interface{} 520 func (fpv *TsConditionTemplate_FieldTerminalPathValue) GetRawValue() interface{} { 521 return fpv.value 522 } 523 func (fpv *TsConditionTemplate_FieldTerminalPathValue) AsNameValue() (*Name, bool) { 524 res, ok := fpv.value.(*Name) 525 return res, ok 526 } 527 func (fpv *TsConditionTemplate_FieldTerminalPathValue) AsMetadataValue() (*meta.Meta, bool) { 528 res, ok := fpv.value.(*meta.Meta) 529 return res, ok 530 } 531 func (fpv *TsConditionTemplate_FieldTerminalPathValue) AsDisplayNameValue() (string, bool) { 532 res, ok := fpv.value.(string) 533 return res, ok 534 } 535 func (fpv *TsConditionTemplate_FieldTerminalPathValue) AsDescriptionValue() (string, bool) { 536 res, ok := fpv.value.(string) 537 return res, ok 538 } 539 func (fpv *TsConditionTemplate_FieldTerminalPathValue) AsSupportingDocsValue() ([]*document.Reference, bool) { 540 res, ok := fpv.value.([]*document.Reference) 541 return res, ok 542 } 543 func (fpv *TsConditionTemplate_FieldTerminalPathValue) AsSpecTemplateValue() (*rcommon.TsCndSpec, bool) { 544 res, ok := fpv.value.(*rcommon.TsCndSpec) 545 return res, ok 546 } 547 548 // SetTo stores value for selected field for object TsConditionTemplate 549 func (fpv *TsConditionTemplate_FieldTerminalPathValue) SetTo(target **TsConditionTemplate) { 550 if *target == nil { 551 *target = new(TsConditionTemplate) 552 } 553 switch fpv.selector { 554 case TsConditionTemplate_FieldPathSelectorName: 555 (*target).Name = fpv.value.(*Name) 556 case TsConditionTemplate_FieldPathSelectorMetadata: 557 (*target).Metadata = fpv.value.(*meta.Meta) 558 case TsConditionTemplate_FieldPathSelectorDisplayName: 559 (*target).DisplayName = fpv.value.(string) 560 case TsConditionTemplate_FieldPathSelectorDescription: 561 (*target).Description = fpv.value.(string) 562 case TsConditionTemplate_FieldPathSelectorSupportingDocs: 563 (*target).SupportingDocs = fpv.value.([]*document.Reference) 564 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 565 (*target).SpecTemplate = fpv.value.(*rcommon.TsCndSpec) 566 default: 567 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fpv.selector)) 568 } 569 } 570 571 func (fpv *TsConditionTemplate_FieldTerminalPathValue) SetToRaw(target proto.Message) { 572 typedObject := target.(*TsConditionTemplate) 573 fpv.SetTo(&typedObject) 574 } 575 576 // CompareWith compares value in the 'TsConditionTemplate_FieldTerminalPathValue' with the value under path in 'TsConditionTemplate'. 577 func (fpv *TsConditionTemplate_FieldTerminalPathValue) CompareWith(source *TsConditionTemplate) (int, bool) { 578 switch fpv.selector { 579 case TsConditionTemplate_FieldPathSelectorName: 580 leftValue := fpv.value.(*Name) 581 rightValue := source.GetName() 582 if leftValue == nil { 583 if rightValue != nil { 584 return -1, true 585 } 586 return 0, true 587 } 588 if rightValue == nil { 589 return 1, true 590 } 591 if leftValue.String() == rightValue.String() { 592 return 0, true 593 } else if leftValue.String() < rightValue.String() { 594 return -1, true 595 } else { 596 return 1, true 597 } 598 case TsConditionTemplate_FieldPathSelectorMetadata: 599 return 0, false 600 case TsConditionTemplate_FieldPathSelectorDisplayName: 601 leftValue := fpv.value.(string) 602 rightValue := source.GetDisplayName() 603 if (leftValue) == (rightValue) { 604 return 0, true 605 } else if (leftValue) < (rightValue) { 606 return -1, true 607 } else { 608 return 1, true 609 } 610 case TsConditionTemplate_FieldPathSelectorDescription: 611 leftValue := fpv.value.(string) 612 rightValue := source.GetDescription() 613 if (leftValue) == (rightValue) { 614 return 0, true 615 } else if (leftValue) < (rightValue) { 616 return -1, true 617 } else { 618 return 1, true 619 } 620 case TsConditionTemplate_FieldPathSelectorSupportingDocs: 621 return 0, false 622 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 623 return 0, false 624 default: 625 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fpv.selector)) 626 } 627 } 628 629 func (fpv *TsConditionTemplate_FieldTerminalPathValue) CompareWithRaw(source proto.Message) (int, bool) { 630 return fpv.CompareWith(source.(*TsConditionTemplate)) 631 } 632 633 type TsConditionTemplate_FieldSubPathValue struct { 634 TsConditionTemplate_FieldPath 635 subPathValue gotenobject.FieldPathValue 636 } 637 638 var _ TsConditionTemplate_FieldPathValue = (*TsConditionTemplate_FieldSubPathValue)(nil) 639 640 func (fpvs *TsConditionTemplate_FieldSubPathValue) AsMetadataPathValue() (meta.Meta_FieldPathValue, bool) { 641 res, ok := fpvs.subPathValue.(meta.Meta_FieldPathValue) 642 return res, ok 643 } 644 func (fpvs *TsConditionTemplate_FieldSubPathValue) AsSpecTemplatePathValue() (rcommon.TsCndSpec_FieldPathValue, bool) { 645 res, ok := fpvs.subPathValue.(rcommon.TsCndSpec_FieldPathValue) 646 return res, ok 647 } 648 649 func (fpvs *TsConditionTemplate_FieldSubPathValue) SetTo(target **TsConditionTemplate) { 650 if *target == nil { 651 *target = new(TsConditionTemplate) 652 } 653 switch fpvs.Selector() { 654 case TsConditionTemplate_FieldPathSelectorMetadata: 655 fpvs.subPathValue.(meta.Meta_FieldPathValue).SetTo(&(*target).Metadata) 656 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 657 fpvs.subPathValue.(rcommon.TsCndSpec_FieldPathValue).SetTo(&(*target).SpecTemplate) 658 default: 659 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fpvs.Selector())) 660 } 661 } 662 663 func (fpvs *TsConditionTemplate_FieldSubPathValue) SetToRaw(target proto.Message) { 664 typedObject := target.(*TsConditionTemplate) 665 fpvs.SetTo(&typedObject) 666 } 667 668 func (fpvs *TsConditionTemplate_FieldSubPathValue) GetRawValue() interface{} { 669 return fpvs.subPathValue.GetRawValue() 670 } 671 672 func (fpvs *TsConditionTemplate_FieldSubPathValue) CompareWith(source *TsConditionTemplate) (int, bool) { 673 switch fpvs.Selector() { 674 case TsConditionTemplate_FieldPathSelectorMetadata: 675 return fpvs.subPathValue.(meta.Meta_FieldPathValue).CompareWith(source.GetMetadata()) 676 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 677 return fpvs.subPathValue.(rcommon.TsCndSpec_FieldPathValue).CompareWith(source.GetSpecTemplate()) 678 default: 679 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fpvs.Selector())) 680 } 681 } 682 683 func (fpvs *TsConditionTemplate_FieldSubPathValue) CompareWithRaw(source proto.Message) (int, bool) { 684 return fpvs.CompareWith(source.(*TsConditionTemplate)) 685 } 686 687 // TsConditionTemplate_FieldPathArrayItemValue allows storing single item in Path-specific values for TsConditionTemplate according to their type 688 // Present only for array (repeated) types. 689 type TsConditionTemplate_FieldPathArrayItemValue interface { 690 gotenobject.FieldPathArrayItemValue 691 TsConditionTemplate_FieldPath 692 ContainsValue(*TsConditionTemplate) bool 693 } 694 695 // ParseTsConditionTemplate_FieldPathArrayItemValue parses string and JSON-encoded value to its Value 696 func ParseTsConditionTemplate_FieldPathArrayItemValue(pathStr, valueStr string) (TsConditionTemplate_FieldPathArrayItemValue, error) { 697 fp, err := ParseTsConditionTemplate_FieldPath(pathStr) 698 if err != nil { 699 return nil, err 700 } 701 fpaiv, err := gotenobject.ParseFieldPathArrayItemValue(fp, valueStr) 702 if err != nil { 703 return nil, status.Errorf(codes.InvalidArgument, "error parsing TsConditionTemplate field path array item value from %s: %v", valueStr, err) 704 } 705 return fpaiv.(TsConditionTemplate_FieldPathArrayItemValue), nil 706 } 707 708 func MustParseTsConditionTemplate_FieldPathArrayItemValue(pathStr, valueStr string) TsConditionTemplate_FieldPathArrayItemValue { 709 fpaiv, err := ParseTsConditionTemplate_FieldPathArrayItemValue(pathStr, valueStr) 710 if err != nil { 711 panic(err) 712 } 713 return fpaiv 714 } 715 716 type TsConditionTemplate_FieldTerminalPathArrayItemValue struct { 717 TsConditionTemplate_FieldTerminalPath 718 value interface{} 719 } 720 721 var _ TsConditionTemplate_FieldPathArrayItemValue = (*TsConditionTemplate_FieldTerminalPathArrayItemValue)(nil) 722 723 // GetRawValue returns stored element value for array in object TsConditionTemplate as interface{} 724 func (fpaiv *TsConditionTemplate_FieldTerminalPathArrayItemValue) GetRawItemValue() interface{} { 725 return fpaiv.value 726 } 727 func (fpaiv *TsConditionTemplate_FieldTerminalPathArrayItemValue) AsSupportingDocsItemValue() (*document.Reference, bool) { 728 res, ok := fpaiv.value.(*document.Reference) 729 return res, ok 730 } 731 732 func (fpaiv *TsConditionTemplate_FieldTerminalPathArrayItemValue) GetSingle(source *TsConditionTemplate) (interface{}, bool) { 733 return nil, false 734 } 735 736 func (fpaiv *TsConditionTemplate_FieldTerminalPathArrayItemValue) GetSingleRaw(source proto.Message) (interface{}, bool) { 737 return fpaiv.GetSingle(source.(*TsConditionTemplate)) 738 } 739 740 // Contains returns a boolean indicating if value that is being held is present in given 'TsConditionTemplate' 741 func (fpaiv *TsConditionTemplate_FieldTerminalPathArrayItemValue) ContainsValue(source *TsConditionTemplate) bool { 742 slice := fpaiv.TsConditionTemplate_FieldTerminalPath.Get(source) 743 for _, v := range slice { 744 if asProtoMsg, ok := fpaiv.value.(proto.Message); ok { 745 if proto.Equal(asProtoMsg, v.(proto.Message)) { 746 return true 747 } 748 } else if reflect.DeepEqual(v, fpaiv.value) { 749 return true 750 } 751 } 752 return false 753 } 754 755 type TsConditionTemplate_FieldSubPathArrayItemValue struct { 756 TsConditionTemplate_FieldPath 757 subPathItemValue gotenobject.FieldPathArrayItemValue 758 } 759 760 // GetRawValue returns stored array item value 761 func (fpaivs *TsConditionTemplate_FieldSubPathArrayItemValue) GetRawItemValue() interface{} { 762 return fpaivs.subPathItemValue.GetRawItemValue() 763 } 764 func (fpaivs *TsConditionTemplate_FieldSubPathArrayItemValue) AsMetadataPathItemValue() (meta.Meta_FieldPathArrayItemValue, bool) { 765 res, ok := fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue) 766 return res, ok 767 } 768 func (fpaivs *TsConditionTemplate_FieldSubPathArrayItemValue) AsSpecTemplatePathItemValue() (rcommon.TsCndSpec_FieldPathArrayItemValue, bool) { 769 res, ok := fpaivs.subPathItemValue.(rcommon.TsCndSpec_FieldPathArrayItemValue) 770 return res, ok 771 } 772 773 // Contains returns a boolean indicating if value that is being held is present in given 'TsConditionTemplate' 774 func (fpaivs *TsConditionTemplate_FieldSubPathArrayItemValue) ContainsValue(source *TsConditionTemplate) bool { 775 switch fpaivs.Selector() { 776 case TsConditionTemplate_FieldPathSelectorMetadata: 777 return fpaivs.subPathItemValue.(meta.Meta_FieldPathArrayItemValue).ContainsValue(source.GetMetadata()) 778 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 779 return fpaivs.subPathItemValue.(rcommon.TsCndSpec_FieldPathArrayItemValue).ContainsValue(source.GetSpecTemplate()) 780 default: 781 panic(fmt.Sprintf("Invalid selector for TsConditionTemplate: %d", fpaivs.Selector())) 782 } 783 } 784 785 // TsConditionTemplate_FieldPathArrayOfValues allows storing slice of values for TsConditionTemplate fields according to their type 786 type TsConditionTemplate_FieldPathArrayOfValues interface { 787 gotenobject.FieldPathArrayOfValues 788 TsConditionTemplate_FieldPath 789 } 790 791 func ParseTsConditionTemplate_FieldPathArrayOfValues(pathStr, valuesStr string) (TsConditionTemplate_FieldPathArrayOfValues, error) { 792 fp, err := ParseTsConditionTemplate_FieldPath(pathStr) 793 if err != nil { 794 return nil, err 795 } 796 fpaov, err := gotenobject.ParseFieldPathArrayOfValues(fp, valuesStr) 797 if err != nil { 798 return nil, status.Errorf(codes.InvalidArgument, "error parsing TsConditionTemplate field path array of values from %s: %v", valuesStr, err) 799 } 800 return fpaov.(TsConditionTemplate_FieldPathArrayOfValues), nil 801 } 802 803 func MustParseTsConditionTemplate_FieldPathArrayOfValues(pathStr, valuesStr string) TsConditionTemplate_FieldPathArrayOfValues { 804 fpaov, err := ParseTsConditionTemplate_FieldPathArrayOfValues(pathStr, valuesStr) 805 if err != nil { 806 panic(err) 807 } 808 return fpaov 809 } 810 811 type TsConditionTemplate_FieldTerminalPathArrayOfValues struct { 812 TsConditionTemplate_FieldTerminalPath 813 values interface{} 814 } 815 816 var _ TsConditionTemplate_FieldPathArrayOfValues = (*TsConditionTemplate_FieldTerminalPathArrayOfValues)(nil) 817 818 func (fpaov *TsConditionTemplate_FieldTerminalPathArrayOfValues) GetRawValues() (values []interface{}) { 819 switch fpaov.selector { 820 case TsConditionTemplate_FieldPathSelectorName: 821 for _, v := range fpaov.values.([]*Name) { 822 values = append(values, v) 823 } 824 case TsConditionTemplate_FieldPathSelectorMetadata: 825 for _, v := range fpaov.values.([]*meta.Meta) { 826 values = append(values, v) 827 } 828 case TsConditionTemplate_FieldPathSelectorDisplayName: 829 for _, v := range fpaov.values.([]string) { 830 values = append(values, v) 831 } 832 case TsConditionTemplate_FieldPathSelectorDescription: 833 for _, v := range fpaov.values.([]string) { 834 values = append(values, v) 835 } 836 case TsConditionTemplate_FieldPathSelectorSupportingDocs: 837 for _, v := range fpaov.values.([][]*document.Reference) { 838 values = append(values, v) 839 } 840 case TsConditionTemplate_FieldPathSelectorSpecTemplate: 841 for _, v := range fpaov.values.([]*rcommon.TsCndSpec) { 842 values = append(values, v) 843 } 844 } 845 return 846 } 847 func (fpaov *TsConditionTemplate_FieldTerminalPathArrayOfValues) AsNameArrayOfValues() ([]*Name, bool) { 848 res, ok := fpaov.values.([]*Name) 849 return res, ok 850 } 851 func (fpaov *TsConditionTemplate_FieldTerminalPathArrayOfValues) AsMetadataArrayOfValues() ([]*meta.Meta, bool) { 852 res, ok := fpaov.values.([]*meta.Meta) 853 return res, ok 854 } 855 func (fpaov *TsConditionTemplate_FieldTerminalPathArrayOfValues) AsDisplayNameArrayOfValues() ([]string, bool) { 856 res, ok := fpaov.values.([]string) 857 return res, ok 858 } 859 func (fpaov *TsConditionTemplate_FieldTerminalPathArrayOfValues) AsDescriptionArrayOfValues() ([]string, bool) { 860 res, ok := fpaov.values.([]string) 861 return res, ok 862 } 863 func (fpaov *TsConditionTemplate_FieldTerminalPathArrayOfValues) AsSupportingDocsArrayOfValues() ([][]*document.Reference, bool) { 864 res, ok := fpaov.values.([][]*document.Reference) 865 return res, ok 866 } 867 func (fpaov *TsConditionTemplate_FieldTerminalPathArrayOfValues) AsSpecTemplateArrayOfValues() ([]*rcommon.TsCndSpec, bool) { 868 res, ok := fpaov.values.([]*rcommon.TsCndSpec) 869 return res, ok 870 } 871 872 type TsConditionTemplate_FieldSubPathArrayOfValues struct { 873 TsConditionTemplate_FieldPath 874 subPathArrayOfValues gotenobject.FieldPathArrayOfValues 875 } 876 877 var _ TsConditionTemplate_FieldPathArrayOfValues = (*TsConditionTemplate_FieldSubPathArrayOfValues)(nil) 878 879 func (fpsaov *TsConditionTemplate_FieldSubPathArrayOfValues) GetRawValues() []interface{} { 880 return fpsaov.subPathArrayOfValues.GetRawValues() 881 } 882 func (fpsaov *TsConditionTemplate_FieldSubPathArrayOfValues) AsMetadataPathArrayOfValues() (meta.Meta_FieldPathArrayOfValues, bool) { 883 res, ok := fpsaov.subPathArrayOfValues.(meta.Meta_FieldPathArrayOfValues) 884 return res, ok 885 } 886 func (fpsaov *TsConditionTemplate_FieldSubPathArrayOfValues) AsSpecTemplatePathArrayOfValues() (rcommon.TsCndSpec_FieldPathArrayOfValues, bool) { 887 res, ok := fpsaov.subPathArrayOfValues.(rcommon.TsCndSpec_FieldPathArrayOfValues) 888 return res, ok 889 }