File: types.go

package info (click to toggle)
golang-github-aws-aws-sdk-go-v2 1.30.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 662,428 kB
  • sloc: java: 16,875; makefile: 432; sh: 175
file content (42 lines) | stat: -rw-r--r-- 788 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package aws

import (
	"fmt"
)

// Ternary is an enum allowing an unknown or none state in addition to a bool's
// true and false.
type Ternary int

func (t Ternary) String() string {
	switch t {
	case UnknownTernary:
		return "unknown"
	case FalseTernary:
		return "false"
	case TrueTernary:
		return "true"
	default:
		return fmt.Sprintf("unknown value, %d", int(t))
	}
}

// Bool returns true if the value is TrueTernary, false otherwise.
func (t Ternary) Bool() bool {
	return t == TrueTernary
}

// Enumerations for the values of the Ternary type.
const (
	UnknownTernary Ternary = iota
	FalseTernary
	TrueTernary
)

// BoolTernary returns a true or false Ternary value for the bool provided.
func BoolTernary(v bool) Ternary {
	if v {
		return TrueTernary
	}
	return FalseTernary
}