-
Notifications
You must be signed in to change notification settings - Fork 27
Expand file tree
/
Copy pathformats.go
More file actions
38 lines (34 loc) · 864 Bytes
/
formats.go
File metadata and controls
38 lines (34 loc) · 864 Bytes
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
package amboy
// Format defines a sequence of constants used to distinguish between
// different serialization formats for job objects used in the
// amboy.ConvertTo and amboy.ConvertFrom functions, which support the
// functionality of the Export and Import methods in the job
// interface.
type Format int
// Supported values of the Format type, which represent different
// supported serialization methods.
const (
BSON Format = iota
JSON
BSON2
)
// String implements fmt.Stringer and pretty prints the format name.
func (f Format) String() string {
switch f {
case JSON:
return "json"
case BSON, BSON2:
return "bson"
default:
return "INVALID"
}
}
// IsValid returns true if when a valid format is specified, and false otherwise
func (f Format) IsValid() bool {
switch f {
case JSON, BSON, BSON2:
return true
default:
return false
}
}