-
Notifications
You must be signed in to change notification settings - Fork 0
/
column.go
61 lines (47 loc) · 909 Bytes
/
column.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
package row
import (
"fmt"
"github.com/buck119br/gears/pkg/gears/core/gtype/common"
)
type Column interface {
fmt.Stringer
Name() common.Key
Value() common.Value
Type() common.Type
IsPK() bool
WithValue(common.Value) Column
}
func NewColumn[V any](n common.Key, v common.Value, t common.Type, isPK bool) Column {
c := &column{
n: n,
v: v,
t: t,
isPK: isPK,
}
return c
}
type column struct {
n common.Key
v common.Value
t common.Type
isPK bool
}
func (c *column) String() string {
return fmt.Sprintf("name: [%s], type: [%s], value: [%s], isPK: [%t]", c.n, c.t, c.v, c.isPK)
}
func (c *column) Name() common.Key {
return c.n
}
func (c *column) Value() common.Value {
return c.v
}
func (c *column) Type() common.Type {
return c.t
}
func (c *column) IsPK() bool {
return c.isPK
}
func (c *column) WithValue(v common.Value) Column {
c.v = v
return c
}