Documentation
¶
Index ¶
- type EitherValue
- func (e *EitherValue[L, LCore, R, RCore]) GetLeft() *L
- func (e *EitherValue[L, LCore, R, RCore]) GetNavigableNode() (any, error)
- func (e *EitherValue[L, LCore, R, RCore]) GetRight() *R
- func (e *EitherValue[L, LCore, R, RCore]) IsEqual(other *EitherValue[L, LCore, R, RCore]) bool
- func (e *EitherValue[L, LCore, R, RCore]) IsLeft() bool
- func (e *EitherValue[L, LCore, R, RCore]) IsRight() bool
- func (e *EitherValue[L, LCore, R, RCore]) LeftValue() L
- func (e *EitherValue[L, LCore, R, RCore]) PopulateWithParent(source any, parent any) error
- func (e *EitherValue[L, LCore, R, RCore]) RightValue() R
- type Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type EitherValue ¶
type EitherValue[L any, LCore any, R any, RCore any] struct { marshaller.Model[core.EitherValue[LCore, RCore]] // Left holds the left-side value. Use directly when setting values in the EitherValue. Left *L // Right holds the right-side value. Use directly when setting values in the EitherValue. Right *R }
EitherValue represents a union type that can hold either a Left or Right value. It provides multiple access patterns for different use cases:
Direct field access (Left, Right) - for setting values Pointer access (GetLeft, GetRight) - for nil-safe pointer retrieval Value access (LeftValue, RightValue) - for nil-safe value retrieval with zero value fallback
func (*EitherValue[L, LCore, R, RCore]) GetLeft ¶
func (e *EitherValue[L, LCore, R, RCore]) GetLeft() *L
GetLeft returns a pointer to the left value in a nil-safe way. Returns nil if the EitherValue is nil or if no left value is set. Use this when you need a pointer to the left value or want to check for nil.
func (*EitherValue[L, LCore, R, RCore]) GetNavigableNode ¶
func (e *EitherValue[L, LCore, R, RCore]) GetNavigableNode() (any, error)
GetNavigableNode implements the NavigableNoder interface to return the held value for JSON pointer navigation
func (*EitherValue[L, LCore, R, RCore]) GetRight ¶
func (e *EitherValue[L, LCore, R, RCore]) GetRight() *R
GetRight returns a pointer to the right value in a nil-safe way. Returns nil if the EitherValue is nil or if no right value is set. Use this when you need a pointer to the right value or want to check for nil.
func (*EitherValue[L, LCore, R, RCore]) IsEqual ¶ added in v1.0.0
func (e *EitherValue[L, LCore, R, RCore]) IsEqual(other *EitherValue[L, LCore, R, RCore]) bool
IsEqual compares two EitherValue instances for equality. It attempts to use IsEqual methods on the contained values if they exist, falling back to reflect.DeepEqual otherwise.
func (*EitherValue[L, LCore, R, RCore]) IsLeft ¶
func (e *EitherValue[L, LCore, R, RCore]) IsLeft() bool
IsLeft returns true if the EitherValue contains a left value. Use this method to check which side of the union is active before accessing values.
func (*EitherValue[L, LCore, R, RCore]) IsRight ¶
func (e *EitherValue[L, LCore, R, RCore]) IsRight() bool
IsRight returns true if the EitherValue contains a right value. Use this method to check which side of the union is active before accessing values.
func (*EitherValue[L, LCore, R, RCore]) LeftValue ¶ added in v1.0.0
func (e *EitherValue[L, LCore, R, RCore]) LeftValue() L
LeftValue returns the left value directly, with zero value fallback for safety. Returns the zero value of type L if the EitherValue is nil or no left value is set. Use this when you need the actual value and want zero value fallback. Should typically be used in conjunction with IsLeft() to verify the value is valid.
func (*EitherValue[L, LCore, R, RCore]) PopulateWithParent ¶ added in v1.4.0
func (e *EitherValue[L, LCore, R, RCore]) PopulateWithParent(source any, parent any) error
func (*EitherValue[L, LCore, R, RCore]) RightValue ¶ added in v1.0.0
func (e *EitherValue[L, LCore, R, RCore]) RightValue() R
RightValue returns the right value directly, with zero value fallback for safety. Returns the zero value of type R if the EitherValue is nil or no right value is set. Use this when you need the actual value and want zero value fallback. Should typically be used in conjunction with IsRight() to verify the value is valid.