/
nullable_string.go
48 lines (40 loc) · 1 KB
/
nullable_string.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
// Copyright 2013, 2014 Peter Vasil, Tomo Krajina. All
// rights reserved. Use of this source code is governed
// by a BSD-style license that can be found in the
// LICENSE file.
package gpx
//NullableString implements a nullable string
type NullableString struct {
data string
notNull bool
}
//Null checks if value is null
func (n *NullableString) Null() bool {
return !n.notNull
}
//NotNull checks if value is not null
func (n *NullableString) NotNull() bool {
return n.notNull
}
//Value returns the value
func (n *NullableString) Value() string {
return n.data
}
//SetValue sets the value
func (n *NullableString) SetValue(data string) {
n.data = data
n.notNull = true
}
//SetNull sets the value to null
func (n *NullableString) SetNull() {
var defaultValue string
n.data = defaultValue
n.notNull = false
}
//NewNullableString creates a new NullableString
func NewNullableString(data string) *NullableString {
result := new(NullableString)
result.data = data
result.notNull = true
return result
}