github.com/cloudwan/edgelq-sdk@v1.15.4/iam/resources/v1alpha2/permission/permission.pb.fieldpath.go (about)

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