github.com/machinefi/w3bstream@v1.6.5-rc9.0.20240426031326-b8c7c4876e72/pkg/enums/flow_operator__generated.go (about) 1 // This is a generated source file. DO NOT EDIT 2 // Source: enums/flow_operator__generated.go 3 4 package enums 5 6 import ( 7 "bytes" 8 "database/sql/driver" 9 "errors" 10 11 "github.com/machinefi/w3bstream/pkg/depends/kit/enum" 12 ) 13 14 var InvalidFlowOperator = errors.New("invalid FlowOperator type") 15 16 func ParseFlowOperatorFromString(s string) (FlowOperator, error) { 17 switch s { 18 default: 19 return FLOW_OPERATOR_UNKNOWN, InvalidFlowOperator 20 case "": 21 return FLOW_OPERATOR_UNKNOWN, nil 22 case "FILTER": 23 return FLOW_OPERATOR__FILTER, nil 24 case "MAP": 25 return FLOW_OPERATOR__MAP, nil 26 case "FLATMAP": 27 return FLOW_OPERATOR__FLATMAP, nil 28 case "WINDOW": 29 return FLOW_OPERATOR__WINDOW, nil 30 case "GROUP": 31 return FLOW_OPERATOR__GROUP, nil 32 case "REDUCE": 33 return FLOW_OPERATOR__REDUCE, nil 34 } 35 } 36 37 func ParseFlowOperatorFromLabel(s string) (FlowOperator, error) { 38 switch s { 39 default: 40 return FLOW_OPERATOR_UNKNOWN, InvalidFlowOperator 41 case "": 42 return FLOW_OPERATOR_UNKNOWN, nil 43 case "FILTER": 44 return FLOW_OPERATOR__FILTER, nil 45 case "MAP": 46 return FLOW_OPERATOR__MAP, nil 47 case "FLATMAP": 48 return FLOW_OPERATOR__FLATMAP, nil 49 case "WINDOW": 50 return FLOW_OPERATOR__WINDOW, nil 51 case "GROUP": 52 return FLOW_OPERATOR__GROUP, nil 53 case "REDUCE": 54 return FLOW_OPERATOR__REDUCE, nil 55 } 56 } 57 58 func (v FlowOperator) Int() int { 59 return int(v) 60 } 61 62 func (v FlowOperator) String() string { 63 switch v { 64 default: 65 return "UNKNOWN" 66 case FLOW_OPERATOR_UNKNOWN: 67 return "" 68 case FLOW_OPERATOR__FILTER: 69 return "FILTER" 70 case FLOW_OPERATOR__MAP: 71 return "MAP" 72 case FLOW_OPERATOR__FLATMAP: 73 return "FLATMAP" 74 case FLOW_OPERATOR__WINDOW: 75 return "WINDOW" 76 case FLOW_OPERATOR__GROUP: 77 return "GROUP" 78 case FLOW_OPERATOR__REDUCE: 79 return "REDUCE" 80 } 81 } 82 83 func (v FlowOperator) Label() string { 84 switch v { 85 default: 86 return "UNKNOWN" 87 case FLOW_OPERATOR_UNKNOWN: 88 return "" 89 case FLOW_OPERATOR__FILTER: 90 return "FILTER" 91 case FLOW_OPERATOR__MAP: 92 return "MAP" 93 case FLOW_OPERATOR__FLATMAP: 94 return "FLATMAP" 95 case FLOW_OPERATOR__WINDOW: 96 return "WINDOW" 97 case FLOW_OPERATOR__GROUP: 98 return "GROUP" 99 case FLOW_OPERATOR__REDUCE: 100 return "REDUCE" 101 } 102 } 103 104 func (v FlowOperator) TypeName() string { 105 return "github.com/machinefi/w3bstream/pkg/enums.FlowOperator" 106 } 107 108 func (v FlowOperator) ConstValues() []enum.IntStringerEnum { 109 return []enum.IntStringerEnum{FLOW_OPERATOR__FILTER, FLOW_OPERATOR__MAP, FLOW_OPERATOR__FLATMAP, FLOW_OPERATOR__WINDOW, FLOW_OPERATOR__GROUP, FLOW_OPERATOR__REDUCE} 110 } 111 112 func (v FlowOperator) MarshalText() ([]byte, error) { 113 s := v.String() 114 if s == "UNKNOWN" { 115 return nil, InvalidFlowOperator 116 } 117 return []byte(s), nil 118 } 119 120 func (v *FlowOperator) UnmarshalText(data []byte) error { 121 s := string(bytes.ToUpper(data)) 122 val, err := ParseFlowOperatorFromString(s) 123 if err != nil { 124 return err 125 } 126 *(v) = val 127 return nil 128 } 129 130 func (v *FlowOperator) Scan(src interface{}) error { 131 offset := 0 132 o, ok := interface{}(v).(enum.ValueOffset) 133 if ok { 134 offset = o.Offset() 135 } 136 i, err := enum.ScanIntEnumStringer(src, offset) 137 if err != nil { 138 return err 139 } 140 *(v) = FlowOperator(i) 141 return nil 142 } 143 144 func (v FlowOperator) Value() (driver.Value, error) { 145 offset := 0 146 o, ok := interface{}(v).(enum.ValueOffset) 147 if ok { 148 offset = o.Offset() 149 } 150 return int64(v) + int64(offset), nil 151 }