-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmapping_properties_builder_options.go
50 lines (39 loc) · 1.48 KB
/
mapping_properties_builder_options.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
package opensearchutil
type MappingPropertiesBuilderOption interface {
apply(*mappingPropertiesBuilderOptionContainer)
}
type mappingPropertiesBuilderOptionContainer struct {
maxDepth uint8
omitUnsupportedTypes bool
fieldNameTransformer FieldNameTransformer
jsonFormatter JsonFormatter
}
// MaxDepth option
type maxDepthOption uint8
func (c maxDepthOption) apply(opts *mappingPropertiesBuilderOptionContainer) {
opts.maxDepth = uint8(c)
}
func WithMaxDepth(maxDepth uint8) MappingPropertiesBuilderOption {
return maxDepthOption(maxDepth)
}
// FieldNameTransformer option
type fieldNameTransformerOption struct {
fieldNameTransformer FieldNameTransformer
}
func (c fieldNameTransformerOption) apply(opts *mappingPropertiesBuilderOptionContainer) {
opts.fieldNameTransformer = c.fieldNameTransformer
}
//goland:noinspection GoUnusedExportedFunction
func WithFieldNameTransformer(fieldNameTransformer FieldNameTransformer) MappingPropertiesBuilderOption {
return fieldNameTransformerOption{fieldNameTransformer: fieldNameTransformer}
}
// OmitUnsupportedTypes option
type skipUnsupportedTypesOption bool
func (c skipUnsupportedTypesOption) apply(opts *mappingPropertiesBuilderOptionContainer) {
opts.omitUnsupportedTypes = bool(c)
}
// OmitUnsupportedTypes makes the builder not complain about types it cannot support. Those would then need to be
// generated manually.
func OmitUnsupportedTypes() MappingPropertiesBuilderOption {
return skipUnsupportedTypesOption(true)
}