object

package
v1.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 10, 2024 License: Apache-2.0 Imports: 12 Imported by: 184

Documentation

Index

Constants

View Source
const (
	PathsFieldName = "paths"
)

Variables

This section is empty.

Functions

func MakeFieldMaskReflection

func MakeFieldMaskReflection(mask FieldMask, pathParser func(raw string) (FieldPath, error)) preflect.Message

Types

type FieldMask

type FieldMask interface {
	fmt.Stringer
	proto.Message

	// ToProtoFieldMask converts to google.protobuf.FieldMask
	ToProtoFieldMask() *fieldmaskpb.FieldMask

	// FromProtoFieldMask erases current contents and re-fills using
	// paths provided by google.protobuf.FieldMask
	FromProtoFieldMask(*fieldmaskpb.FieldMask) error

	// AppendRawPath appends new field path
	AppendRawPath(path FieldPath)

	// SubtractRaw creates new FieldMask by subtracting current
	// instance from the one given as argument.
	// Subtracting operation is using following rules:
	// * F1 {A, C} - F2 {A, B} = F3 {C} (A removes A)
	// * F1 {A} - F2 {A.B} = F3 {A.X1, ... A.Xn} (where X
	//   is any possible subpath of A that is not B).
	//   Exception to this rule are field paths containing
	//   map keys, where possible Xn combinations are
	//   open-ended. Sub-paths ending on map leaves are
	//   ignored in F2 (left side argument).
	// * F1 {A.B} - F2 {A} = F3 {} (if we remove A, we remove
	//   all sub-paths of A too).
	SubtractRaw(other FieldMask) FieldMask

	// GetRawPaths returns all current field paths
	GetRawPaths() []FieldPath

	// IsFull indicates if mask is full. Mask is considered as
	// full, if proto.Equal(a, mask.CloneRaw(a)) equals
	// true.
	IsFull() bool

	// SetRaw copies shallowly values pointed by internally hold
	// fields paths from source to the target.
	SetRaw(target, source GotenObjectExt)

	// ProjectRaw makes projection (shallow copy) of the given
	// resource for internal field paths only.
	// If the mask is nil, then same object is returned.
	ProjectRaw(source GotenObjectExt) GotenObjectExt

	// PathsCount returns number of field paths included
	PathsCount() int
}

FieldMask describes an interface Interface of goten field mask.

type FieldPath

type FieldPath interface {
	fmt.Stringer
	JSONString() string
	GetRaw(proto.Message) []interface{}
	GetSingleRaw(proto.Message) (interface{}, bool)
	GetDefault() interface{}
	ClearValueRaw(item proto.Message)
	WithRawIValue(value interface{}) FieldPathValue
	WithRawIArrayOfValues(values interface{}) FieldPathArrayOfValues
	WithRawIArrayItemValue(value interface{}) FieldPathArrayItemValue
	IsLeaf() bool
	SplitIntoTerminalIPaths() []FieldPath
}

type FieldPathArrayItemValue

type FieldPathArrayItemValue interface {
	FieldPath
	GetRawItemValue() interface{}
}

func ParseFieldPathArrayItemValue

func ParseFieldPathArrayItemValue(fp FieldPath, valueStr string) (FieldPathArrayItemValue, error)

type FieldPathArrayOfValues

type FieldPathArrayOfValues interface {
	FieldPath
	GetRawValues() []interface{}
}

func ParseFieldPathArrayOfValues

func ParseFieldPathArrayOfValues(fp FieldPath, valuesStr string) (FieldPathArrayOfValues, error)

type FieldPathValue

type FieldPathValue interface {
	FieldPath
	GetRawValue() interface{}
	SetToRaw(target proto.Message)
	CompareWithRaw(msg proto.Message) (cmp int, comparable bool)
}

func ParseFieldPathValue

func ParseFieldPathValue(fp FieldPath, valueStr string) (FieldPathValue, error)

type GotenObjectExt

type GotenObjectExt interface {
	fmt.Stringer
	proto.Message
	GotenObjectExt()

	// CloneRaw clones current object.
	CloneRaw() GotenObjectExt

	// MergeRaw merges provided source into current object.
	MergeRaw(GotenObjectExt)

	// MakeRawFullFieldMask returns full mask. Full field mask contains
	// paths of all fields without sub paths items,
	// as it is considered that field path already contains
	// sub paths.
	MakeRawFullFieldMask() FieldMask

	// MakeRawDiffFieldMask returns diff mask compared with given resource.
	// Panics, if other resource is not of same type.
	MakeRawDiffFieldMask(other GotenObjectExt) FieldMask
}

GotenObjectExt is implemented by a Go representation of a protobuf message for which protoc-goten-gen-object plugin was used. GotenObjectExt is basically an extension of a regular go-protobuf object containing many additional goten-specific features like type-safe embedded field paths, field masks, diff support, customized merge support etc. Those extensions are mandatory resources, optional for others.

type RawFieldPath

type RawFieldPath []string

func ParseRawFieldPath

func ParseRawFieldPath(rawPath string) (RawFieldPath, error)

func (RawFieldPath) LastItem

func (fp RawFieldPath) LastItem() string

func (RawFieldPath) String

func (fp RawFieldPath) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL