types

package
v0.0.21 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 1 Imported by: 4

Documentation

Overview

Package types provides utility types and functions. Copyright (c) APIMatic. All rights reserved.

Index

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
}

Optional is a generic struct that allows any type to be used as optional and nullable. Optional.set is true when Optional.value is to be used.

func EmptyOptional

func EmptyOptional[T any]() Optional[T]

EmptyOptional creates and returns an empty Optional instance with no value set.

func NewOptional

func NewOptional[T any](value *T) Optional[T]

NewOptional creates and returns an Optional instance with the given value set.

func (*Optional[T]) IsValueSet

func (o *Optional[T]) IsValueSet() bool

IsValueSet returns true if a value is set in the Optional, false otherwise.

func (*Optional[T]) SetValue

func (o *Optional[T]) SetValue(value *T)

SetValue sets the value of the Optional.

func (*Optional[T]) ShouldSetValue

func (o *Optional[T]) ShouldSetValue(set bool)

ShouldSetValue sets whether the value should be used or not.

func (*Optional[T]) UnmarshalJSON

func (o *Optional[T]) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals the JSON input into the Optional value.

func (*Optional[T]) Value

func (o *Optional[T]) Value() *T

Value returns the value stored in the Optional. It returns nil if no value is set.

Jump to

Keyboard shortcuts

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