-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtable.go
35 lines (28 loc) · 1012 Bytes
/
table.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
package gotidus
// NewTable initializes a Table object wich blank columns.
func NewTable() *Table {
table := &Table{
columns: make(map[string]Anonymizer),
}
return table
}
// Table is the type holding the column configuration
type Table struct {
columns map[string]Anonymizer
}
// AddAnonymizer allows setting a specific Anonymizer for a column of the given name.
// If an Anonymizer was previously configured for a column name, it will be overwritten.
func (t *Table) AddAnonymizer(columnName string, anonymizer Anonymizer) *Table {
t.columns[columnName] = anonymizer
return t
}
// GetAnonymizer retrieves an Anonymizer from the Table configuration.
// If an Anonymizer was configured for the given name, that Anonymizer will be returned.
// If no Anonymizer was configured for the given name, the NoopAnonymizer will be returned.
func (t *Table) GetAnonymizer(columnName string) Anonymizer {
anonymizer, ok := t.columns[columnName]
if ok {
return anonymizer
}
return NewNoopAnonymizer()
}