-
Notifications
You must be signed in to change notification settings - Fork 6
/
play_builder.go
76 lines (66 loc) · 1.96 KB
/
play_builder.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
// DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
// Autogenerated by buildergenerator
package goexoml
import (
"errors"
)
var _ = errors.New("_")
// SetLoop sets Loop for Play struct instance
func (playReceiver *Play) SetLoop(loop int) *Play {
playReceiver.Loop = loop
return playReceiver
}
// SetDigits sets Digits for Play struct instance
func (playReceiver *Play) SetDigits(digits int) *Play {
playReceiver.Digits = digits
return playReceiver
}
// SetURL sets URL for Play struct instance
func (playReceiver *Play) SetURL(url string) *Play {
playReceiver.URL = url
return playReceiver
}
// Setter returns setter function for the field given
func (playReceiver *Play) Setter(field string) (setter func(interface{}) (*Play, error)) {
switch field {
case "Loop":
setter = func(LoopField interface{}) (*Play, error) {
if LoopValue, ok := LoopField.(int); ok {
return playReceiver.SetLoop(LoopValue), nil
}
return nil, errors.New("Invalid type Expected int ")
}
case "Digits":
setter = func(DigitsField interface{}) (*Play, error) {
if DigitsValue, ok := DigitsField.(int); ok {
return playReceiver.SetDigits(DigitsValue), nil
}
return nil, errors.New("Invalid type Expected int ")
}
case "URL":
setter = func(URLField interface{}) (*Play, error) {
if URLValue, ok := URLField.(string); ok {
return playReceiver.SetURL(URLValue), nil
}
return nil, errors.New("Invalid type Expected string ")
}
}
return
}
// NewPlay return a new Play pointer
func NewPlay() *Play {
return new(Play)
}
// IPlay The interface that satisfies all the methods for this struct
// IPlay asserts implementation of setters for all the fields of Play
type IPlay interface {
SetLoop(loop int) *Play
SetDigits(digits int) *Play
SetURL(url string) *Play
Setter(string) func(interface{}) (*Play, error)
}
// AddPlay appends the verb to response
func (r *Response) AddPlay(play IPlay) *Response {
r.Response = append(r.Response, play)
return r
}