-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenerated.struct.go
83 lines (64 loc) · 4.03 KB
/
generated.struct.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package dstruct
import (
"github.com/MartinSimango/dstruct/generator"
"github.com/MartinSimango/dstruct/generator/config"
"github.com/MartinSimango/dstruct/generator/core"
)
type GeneratedFieldContexts map[string]*core.GeneratedFieldContext
type GeneratedStruct interface {
DynamicStructModifier
// Generate generates fields for the struct. If new fields are generated, the root tree for the underlying
// struct is updated. This allows new generated fields to be accessed and modified by Set and Get methods
Generate()
// SetFieldGenerationSettings sets the generation value config for field within the struct.
// If the field does not exist or if the field has no generation settings an error is returned.
SetFieldGenerationSettings(
field string,
settings config.GenerationSettings,
) error
// GetFieldGenerationSettings gets the generation config for field within the struct.
// If the field does not exist or if the field has no generation settings an error is returned.
GetFieldGenerationSettings(field string) (config.GenerationSettings, error)
// GetFieldGenerationSettings_ is like GetFieldGenerationSettings but panics if an error occurs.
GetFieldGenerationSettings_(field string) config.GenerationSettings
// SetGenerationSettings sets the generation settings for the struct and propagates the settings to all fields
SetGenerationSettings(settings config.GenerationSettings)
// GetGenerationSettings gets the generation settings for the struct.
GetGenerationSettings() config.GenerationSettings
// SetFieldGenerationConfig sets the generation config for field within the struct. It returns
// an error if the field does not exist or if the field cannot be generated.
// Fields that can be generated are struct fields of the most basic type i.e a struct fields
// that are structs cannot be generated, however it's fields can be.
//
// Fields types that cannot be generated: structs, func, chan, any (will default to a nil value being generated).
//
// Note: Pointers to structs can be generated.
SetFieldGenerationConfig(field string, generationConfig config.Config) error
// GetFieldGenerationConfig gets the generation config for field within the struct.
GetFieldGenerationConfig(field string) (config.Config, error)
// GetFieldGenerationConfig_ is like GetFieldGenerationConfig but panics if an error occurs.
GetFieldGenerationConfig_(field string) config.Config
// SetGenerationConfig sets the generation config for the struct and propagates the settings to all fields
SetGenerationConfig(config config.Config)
// GetGenerationConfig gets the generation config for the struct.
GetGenerationConfig() config.Config
// SetFieldGenerationFunction sets the generation function for field within the struct. It returns an error if the field does not exist or if the field cannot be generated.
SetFieldGenerationFunction(field string, functionHolder core.FunctionHolder) error
// // GetFieldGenerationConfig gets the generation function for field within the struct.
// GetFieldGenerationFunction(field string) (core.FunctionHolder, error)
//
// // GetFieldGenerationFunction_ is like GetFieldGenerationFunction but panics if an error occurs.
// GetFieldGenerationFunction_(field string) core.FunctionHolder
//
// SetFieldDefaultFunctions sets the default generation functions for field within the struct. It returns an error if the field does not exist or if the field cannot be generated.
SetFieldGenerationFunctions(field string, functions core.DefaultGenerationFunctions) error
// SetGenerationFunctions sets the generation functions for the struct and propagates the settings to all fields
SetGenerationFunctions(functions core.DefaultGenerationFunctions)
// SetFieldFromTaskInstance sets the field value from the task instance. The task is used to generate the value for the field.
SetFieldFromTaskInstance(
field string,
taskInstance generator.TaskInstance,
) error
// AddCustomType adds a custom type to the struct. The custom type is used to generate values for fields of the custom type.
AddCustomType(customType CustomType)
}