This repository has been archived by the owner on Dec 30, 2024. It is now read-only.
generated from FrangipaneTeam/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnumber_value.go
81 lines (63 loc) · 1.89 KB
/
number_value.go
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
// -------------------------------------------------------------------- //
// ! DO NOT EDIT. This file is auto-generated from template ! //
// -------------------------------------------------------------------- //
package supertypes
import (
"context"
"math/big"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
)
// Ensure the implementation satisfies the expected interfaces.
var _ basetypes.NumberValuable = NumberValue{}
type NumberValue struct {
basetypes.NumberValue
}
func (v NumberValue) Equal(o attr.Value) bool {
other, ok := o.(NumberValue)
if !ok {
return false
}
return v.NumberValue.Equal(other.NumberValue)
}
func (v NumberValue) Type(ctx context.Context) attr.Type {
return NumberType{
NumberType: v.NumberValue.Type(ctx).(basetypes.NumberType),
}
}
func NewNumberNull() NumberValue {
return NumberValue{
NumberValue: basetypes.NewNumberNull(),
}
}
func NewNumberUnknown() NumberValue {
return NumberValue{
NumberValue: basetypes.NewNumberUnknown(),
}
}
func NewNumberValue(s *big.Float) NumberValue {
return NumberValue{
NumberValue: basetypes.NewNumberValue(s),
}
}
// * CustomFunc
// Get returns the known Number value. If Number is null or unknown, returns 0.0.
func (v *NumberValue) Get() *big.Float {
return v.NumberValue.ValueBigFloat()
}
// Set sets the Number value.
func (v *NumberValue) Set(s *big.Float) {
v.NumberValue = basetypes.NewNumberValue(s)
}
// SetNull sets the Number value to null.
func (v *NumberValue) SetNull() {
v.NumberValue = basetypes.NewNumberNull()
}
// SetUnknown sets the Number value to unknown.
func (v *NumberValue) SetUnknown() {
v.NumberValue = basetypes.NewNumberUnknown()
}
// IsKnown returns true if the value is not null and not unknown.
func (v NumberValue) IsKnown() bool {
return !v.NumberValue.IsNull() && !v.NumberValue.IsUnknown()
}