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 pathstring_value.go
106 lines (84 loc) · 2.47 KB
/
string_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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
// -------------------------------------------------------------------- //
// ! DO NOT EDIT. This file is auto-generated from template ! //
// -------------------------------------------------------------------- //
package supertypes
import (
"context"
"github.com/hashicorp/terraform-plugin-framework/attr"
"github.com/hashicorp/terraform-plugin-framework/types/basetypes"
)
// Ensure the implementation satisfies the expected interfaces.
var _ basetypes.StringValuable = StringValue{}
type StringValue struct {
basetypes.StringValue
}
func (v StringValue) Equal(o attr.Value) bool {
other, ok := o.(StringValue)
if !ok {
return false
}
return v.StringValue.Equal(other.StringValue)
}
func (v StringValue) Type(ctx context.Context) attr.Type {
return StringType{
StringType: v.StringValue.Type(ctx).(basetypes.StringType),
}
}
func NewStringNull() StringValue {
return StringValue{
StringValue: basetypes.NewStringNull(),
}
}
func NewStringUnknown() StringValue {
return StringValue{
StringValue: basetypes.NewStringUnknown(),
}
}
func NewStringValue(s string) StringValue {
return StringValue{
StringValue: basetypes.NewStringValue(s),
}
}
func NewStringPointerValue(s *string) StringValue {
return StringValue{
StringValue: basetypes.NewStringPointerValue(s),
}
}
// * CustomFunc
// Get returns the known String value. If String is null or unknown, returns "".
func (v *StringValue) Get() string {
return v.StringValue.ValueString()
}
// GetPtr returns a pointer to the known int64 value, nil for a
// null value, or a pointer to 0 for an unknown value.
func (v *StringValue) GetPtr() *string {
return v.StringValue.ValueStringPointer()
}
// Set sets the String value.
func (v *StringValue) Set(s string) {
if s == "" {
v.StringValue = basetypes.NewStringNull()
return
}
v.StringValue = basetypes.NewStringValue(s)
}
// SetPtr sets a pointer to the String value.
func (v *StringValue) SetPtr(s *string) {
if s == nil {
v.StringValue = basetypes.NewStringNull()
return
}
v.StringValue = basetypes.NewStringPointerValue(s)
}
// SetNull sets the String value to null.
func (v *StringValue) SetNull() {
v.StringValue = basetypes.NewStringNull()
}
// SetUnknown sets the String value to unknown.
func (v *StringValue) SetUnknown() {
v.StringValue = basetypes.NewStringUnknown()
}
// IsKnown returns true if the value is not null and not unknown.
func (v StringValue) IsKnown() bool {
return !v.StringValue.IsNull() && !v.StringValue.IsUnknown()
}