Documentation
¶
Index ¶
- type Optional
- func (o Optional[T]) Exists() bool
- func (o Optional[T]) Get() (T, bool)
- func (o Optional[Value]) GetOrElse(defaultValue Value) Value
- func (o Optional[Value]) MarshalJSON() ([]byte, error)
- func (o Optional[Value]) MustGet() Value
- func (o *Optional[Value]) UnmarshalJSON(data []byte) error
- func (o Optional[Value]) Value() Value
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Optional ¶
type Optional[T any] struct { // contains filtered or unexported fields }
func (Optional[T]) Get ¶
Get returns the value and whether it exists. It's invalid to use the returned value if the bool is false.
func (Optional[Value]) GetOrElse ¶
func (o Optional[Value]) GetOrElse(defaultValue Value) Value
GetOrElse returns the value if it exists and returns defaultValue otherwise.
func (Optional[Value]) MarshalJSON ¶
MarshalJSON implements the json.Marshaller interface. Optionals wil marshall and unmarshall as a nullable json field. Value type must also implement json.Marshaller.
func (Optional[Value]) MustGet ¶
func (o Optional[Value]) MustGet() Value
MustGet returns the value if it exists and panics otherwise.
func (*Optional[Value]) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface. Optionals will marshall and unmarshall as a nullable json field. Value type must also implement json.Unmarshaler.
Click to show internal directories.
Click to hide internal directories.