/
types.go
46 lines (37 loc) · 1.17 KB
/
types.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
package v3
import (
"strings"
"unicode"
orm "github.com/regen-network/regen-ledger/orm"
)
type BatchDenomT string
var _, _, _ orm.PrimaryKeyed = &ClassInfo{}, &BatchInfo{}, &CreditTypeSeq{}
// PrimaryKeyFields returns the fields of the object that will make up the
// primary key for ClassInfo.
func (m *ClassInfo) PrimaryKeyFields() []interface{} {
return []interface{}{m.ClassId}
}
// PrimaryKeyFields returns the fields of the object that will make up the
// primary key for BatchInfo.
func (m *BatchInfo) PrimaryKeyFields() []interface{} {
return []interface{}{m.BatchDenom}
}
// PrimaryKeyFields returns the fields of the object that will make up the
// primary key for CreditTypeSeq.
func (m *CreditTypeSeq) PrimaryKeyFields() []interface{} {
return []interface{}{m.Abbreviation}
}
// NormalizeCreditTypeName credit type name by removing whitespace and converting to lowercase.
func NormalizeCreditTypeName(name string) string {
return fastRemoveWhitespace(strings.ToLower(name))
}
func fastRemoveWhitespace(str string) string {
var b strings.Builder
b.Grow(len(str))
for _, ch := range str {
if !unicode.IsSpace(ch) {
b.WriteRune(ch)
}
}
return b.String()
}