@@ -23,13 +23,13 @@ type DataDictionary struct {
23
23
Trailer * MessageDef
24
24
}
25
25
26
- // MessagePart can represent a Field, Repeating Group, or Component
26
+ // MessagePart can represent a Field, Repeating Group, or Component.
27
27
type MessagePart interface {
28
28
Name () string
29
29
Required () bool
30
30
}
31
31
32
- // messagePartWithFields is a MessagePart with multiple Fields
32
+ // messagePartWithFields is a MessagePart with multiple Fields.
33
33
type messagePartWithFields interface {
34
34
MessagePart
35
35
Fields () []* FieldDef
@@ -45,7 +45,7 @@ type ComponentType struct {
45
45
requiredParts []MessagePart
46
46
}
47
47
48
- // NewComponentType returns an initialized component type
48
+ // NewComponentType returns an initialized component type.
49
49
func NewComponentType (name string , parts []MessagePart ) * ComponentType {
50
50
comp := ComponentType {
51
51
name : name ,
@@ -77,20 +77,20 @@ func NewComponentType(name string, parts []MessagePart) *ComponentType {
77
77
return & comp
78
78
}
79
79
80
- // Name returns the name of this component type
80
+ // Name returns the name of this component type.
81
81
func (c ComponentType ) Name () string { return c .name }
82
82
83
83
// Fields returns all fields contained in this component. Includes fields
84
- // encapsulated in components of this component
84
+ // encapsulated in components of this component.
85
85
func (c ComponentType ) Fields () []* FieldDef { return c .fields }
86
86
87
- // RequiredFields returns those fields that are required for this component
87
+ // RequiredFields returns those fields that are required for this component.
88
88
func (c ComponentType ) RequiredFields () []* FieldDef { return c .requiredFields }
89
89
90
- // RequiredParts returns those parts that are required for this component
90
+ // RequiredParts returns those parts that are required for this component.
91
91
func (c ComponentType ) RequiredParts () []MessagePart { return c .requiredParts }
92
92
93
- // Parts returns all parts in declaration order contained in this component
93
+ // Parts returns all parts in declaration order contained in this component.
94
94
func (c ComponentType ) Parts () []MessagePart { return c .parts }
95
95
96
96
// TagSet is set for tags.
@@ -101,13 +101,13 @@ func (t TagSet) Add(tag int) {
101
101
t [tag ] = struct {}{}
102
102
}
103
103
104
- // Component is a Component as it appears in a given MessageDef
104
+ // Component is a Component as it appears in a given MessageDef.
105
105
type Component struct {
106
106
* ComponentType
107
107
required bool
108
108
}
109
109
110
- // NewComponent returns an initialized Component instance
110
+ // NewComponent returns an initialized Component instance.
111
111
func NewComponent (ct * ComponentType , required bool ) * Component {
112
112
return & Component {
113
113
ComponentType : ct ,
@@ -116,10 +116,10 @@ func NewComponent(ct *ComponentType, required bool) *Component {
116
116
}
117
117
118
118
// Required returns true if this component is required for the containing
119
- // MessageDef
119
+ // MessageDef.
120
120
func (c Component ) Required () bool { return c .required }
121
121
122
- // Field models a field or repeating group in a message
122
+ // Field models a field or repeating group in a message.
123
123
type Field interface {
124
124
Tag () int
125
125
}
@@ -135,15 +135,15 @@ type FieldDef struct {
135
135
requiredFields []* FieldDef
136
136
}
137
137
138
- // NewFieldDef returns an initialized FieldDef
138
+ // NewFieldDef returns an initialized FieldDef.
139
139
func NewFieldDef (fieldType * FieldType , required bool ) * FieldDef {
140
140
return & FieldDef {
141
141
FieldType : fieldType ,
142
142
required : required ,
143
143
}
144
144
}
145
145
146
- // NewGroupFieldDef returns an initialized FieldDef for a repeating group
146
+ // NewGroupFieldDef returns an initialized FieldDef for a repeating group.
147
147
func NewGroupFieldDef (fieldType * FieldType , required bool , parts []MessagePart ) * FieldDef {
148
148
field := FieldDef {
149
149
FieldType : fieldType ,
@@ -179,7 +179,7 @@ func NewGroupFieldDef(fieldType *FieldType, required bool, parts []MessagePart)
179
179
}
180
180
181
181
// Required returns true if this FieldDef is required for the containing
182
- // MessageDef
182
+ // MessageDef.
183
183
func (f FieldDef ) Required () bool { return f .required }
184
184
185
185
// IsGroup is true if the field is a repeating group.
@@ -188,11 +188,11 @@ func (f FieldDef) IsGroup() bool {
188
188
}
189
189
190
190
// RequiredParts returns those parts that are required for this FieldDef. IsGroup
191
- // must return true
191
+ // must return true.
192
192
func (f FieldDef ) RequiredParts () []MessagePart { return f .requiredParts }
193
193
194
194
// RequiredFields returns those fields that are required for this FieldDef. IsGroup
195
- // must return true
195
+ // must return true.
196
196
func (f FieldDef ) RequiredFields () []* FieldDef { return f .requiredFields }
197
197
198
198
func (f FieldDef ) childTags () []int {
@@ -214,7 +214,7 @@ type FieldType struct {
214
214
Enums map [string ]Enum
215
215
}
216
216
217
- // NewFieldType returns a pointer to an initialized FieldType
217
+ // NewFieldType returns a pointer to an initialized FieldType.
218
218
func NewFieldType (name string , tag int , fixType string ) * FieldType {
219
219
return & FieldType {
220
220
name : name ,
@@ -223,10 +223,10 @@ func NewFieldType(name string, tag int, fixType string) *FieldType {
223
223
}
224
224
}
225
225
226
- // Name returns the name for this FieldType
226
+ // Name returns the name for this FieldType.
227
227
func (f FieldType ) Name () string { return f .name }
228
228
229
- // Tag returns the tag for this fieldType
229
+ // Tag returns the tag for this fieldType.
230
230
func (f FieldType ) Tag () int { return f .tag }
231
231
232
232
// Enum is a container for value and description.
@@ -240,19 +240,18 @@ type MessageDef struct {
240
240
Name string
241
241
MsgType string
242
242
Fields map [int ]* FieldDef
243
- //Parts are the MessageParts of contained in this MessageDef in declaration
244
- //order
243
+ // Parts are the MessageParts of contained in this MessageDef in declaration order.
245
244
Parts []MessagePart
246
245
requiredParts []MessagePart
247
246
248
247
RequiredTags TagSet
249
248
Tags TagSet
250
249
}
251
250
252
- // RequiredParts returns those parts that are required for this Message
251
+ // RequiredParts returns those parts that are required for this Message.
253
252
func (m MessageDef ) RequiredParts () []MessagePart { return m .requiredParts }
254
253
255
- // NewMessageDef returns a pointer to an initialized MessageDef
254
+ // NewMessageDef returns a pointer to an initialized MessageDef.
256
255
func NewMessageDef (name , msgType string , parts []MessagePart ) * MessageDef {
257
256
msg := MessageDef {
258
257
Name : name ,
@@ -283,8 +282,8 @@ func NewMessageDef(name, msgType string, parts []MessagePart) *MessageDef {
283
282
switch pType := part .(type ) {
284
283
case messagePartWithFields :
285
284
for _ , f := range pType .Fields () {
286
- //field if required in component is required in message only if
287
- //component is required
285
+ // Field if required in component is required in message only if
286
+ // component is required.
288
287
processField (f , pType .Required ())
289
288
}
290
289
0 commit comments