j5reflect

package
v0.0.0-...-38d2136 Latest Latest
Warning

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

Go to latest
Published: Jan 2, 2025 License: MIT Imports: 19 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ASTValue

type ASTValue interface {
	AsBool() (bool, error)
	AsString() (string, error)
	AsInt(bits int) (int64, error)
	AsUint(bits int) (uint64, error)
	AsFloat(bits int) (float64, error)
}

type AnyField

type AnyField interface {
	Field

	SetJ5Any(val *any_j5t.Any) error
	GetJ5Any() (*any_j5t.Any, error)
	SetProtoAny(val *anypb.Any) error
	GetProtoAny() (*anypb.Any, error)
}

type AnyValue

type AnyValue interface{}

type ArrayField

type ArrayField interface {
	Field
	ItemSchema() j5schema.FieldSchema
	RangeValues(RangeArrayCallback) error
	Length() int
	Truncate(int)
}

type ArrayOfContainerField

type ArrayOfContainerField interface {
	MutableArrayField
	NewContainerElement() (ContainerField, int)
	RangeContainers(func(int, ContainerField) error) error
}

type ArrayOfEnumField

type ArrayOfEnumField interface {
	ArrayOfScalarField
	AppendEnumFromString(string) (int, error)
}

type ArrayOfObjectField

type ArrayOfObjectField interface {
	ArrayOfContainerField
	NewObjectElement() (ObjectField, int)
}

type ArrayOfOneofField

type ArrayOfOneofField interface {
	ArrayOfContainerField
	NewOneofElement() (Oneof, int, error)
}

type ArrayOfScalarField

type ArrayOfScalarField interface {
	ArrayField
	AppendGoValue(value interface{}) (int, error)
	AppendASTValue(ASTValue) (int, error)
}

type ContainerField

type ContainerField interface {
	PropertySet
	Field
}

type EnumField

type EnumField interface {
	Field
	GetValue() (EnumOption, error)
	SetFromString(string) error
}

type EnumOption

type EnumOption interface {
	Name() string
	Number() int32
	Description() string
}

type Field

type Field interface {
	IsSet() bool
	FieldContext

	AsScalar() (ScalarField, bool)
	AsEnum() (EnumField, bool)

	AsContainer() (ContainerField, bool)
	AsObject() (ObjectField, bool)
	AsOneof() (OneofField, bool)

	AsArray() (ArrayField, bool)
	AsArrayOfScalar() (ArrayOfScalarField, bool)
	AsArrayOfContainer() (ArrayOfContainerField, bool)
	AsArrayOfOneof() (ArrayOfOneofField, bool)
	AsArrayOfObject() (ArrayOfObjectField, bool)

	AsMap() (MapField, bool)
	AsMapOfScalar() (MapOfScalarField, bool)
	AsMapOfContainer() (MapOfContainerField, bool)
	AsMapOfObject() (MapOfObjectField, bool)
	AsMapOfOneof() (MapOfOneofField, bool)
}

type FieldContext

type FieldContext interface {
	// NameInParent is the name this field in the parent
	// Object and Oneof: The property name
	// Map<string>x, the key
	// Arrays, the index as a string
	NameInParent() string

	// IndexInParent returns -1 for non array fields
	IndexInParent() int
	PropertySchema() *schema_j5pb.ObjectProperty
	FieldSchema() schema_j5pb.IsField_Type
	TypeName() string
	FullTypeName() string
	ProtoPath() []string
}

type LeafMapField

type LeafMapField interface {
	MapField
}

type MapField

type MapField interface {
	Field
	ItemSchema() j5schema.FieldSchema
	Range(RangeMapCallback) error
	NewElement(key string) (Field, error)
	GetOrCreateElement(key string) (Field, error)
}

type MapOfContainerField

type MapOfContainerField interface {
	MutableMapField
	NewContainerElement(key string) (ContainerField, error)
}

type MapOfEnumField

type MapOfEnumField interface {
	SetEnum(key string, value string) error
}

type MapOfObjectField

type MapOfObjectField interface {
	NewObjectElement(key string) (ObjectField, error)
}

type MapOfOneofField

type MapOfOneofField interface {
	NewOneofElement(key string) (OneofField, error)
}

type MapOfScalarField

type MapOfScalarField interface {
	SetGoValue(key string, value interface{}) error
	SetASTValue(key string, value ASTValue) error
}

type MutableArrayField

type MutableArrayField interface {
	ArrayField
	NewElement() Field
}

type MutableMapField

type MutableMapField interface {
	MapField
}

type Object

type Object interface {
	PropertySet

	// HasAnyValue returns true if any of the properties have a valid value
	HasAnyValue() bool
}

type ObjectField

type ObjectField interface {
	Object
	Field
}

type Oneof

type Oneof interface {
	PropertySet

	// GetOne returns the value existing in the oneof, or false if nothing is set.
	GetOne() (Field, bool, error)
}

type OneofField

type OneofField interface {
	Oneof
	Field
}

type Property

type Property interface {
	IsSet() bool
	Schema() *j5schema.ObjectProperty
	Field() (Field, error)

	IsArray() bool
	IsMap() bool
}

type PropertySet

type PropertySet interface {
	SchemaName() string // Returns the full name of the entity wrapping the properties.

	ContainerSchema() j5schema.Container

	RangeProperties(RangePropertiesCallback) error
	RangePropertySchemas(RangePropertySchemasCallback) error
	RangeValues(RangeValuesCallback) error

	// HasProperty returns true if there is a property with the given name in
	// the *schema* for the property set.
	HasProperty(name string) bool

	// GetProperty returns the property with the given name in the schema for
	// the property set. The property may not be set to a value.
	GetProperty(name string) (Property, error)

	GetValue(name string) (Field, bool, error)
	NewValue(name string) (Field, error)
	GetOrCreateValue(name string) (Field, error)

	ListPropertyNames() []string
	// contains filtered or unexported methods
}

PropertySet is implemented by Oneofs, Objects and Maps with String keys.

type RangeArrayCallback

type RangeArrayCallback func(int, Field) error

type RangeMapCallback

type RangeMapCallback func(string, Field) error

type RangePropertiesCallback

type RangePropertiesCallback func(Property) error

type RangePropertySchemasCallback

type RangePropertySchemasCallback func(name string, required bool, schema *schema_j5pb.Field) error

type RangeValuesCallback

type RangeValuesCallback func(Field) error

type Reflector

type Reflector struct {
	// contains filtered or unexported fields
}

func New

func New() *Reflector

func NewWithCache

func NewWithCache(cache *j5schema.SchemaCache) *Reflector

func (*Reflector) NewObject

func (r *Reflector) NewObject(msg protoreflect.Message) (*objectImpl, error)

func (*Reflector) NewRoot

func (r *Reflector) NewRoot(msg protoreflect.Message) (Root, error)

type Root

type Root interface {
	PropertySet
}

type ScalarField

type ScalarField interface {
	Field
	ToGoValue() (interface{}, error)
	SetGoValue(value interface{}) error
	SetASTValue(ASTValue) error
}

Jump to

Keyboard shortcuts

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