go.charczuk.com@v0.0.0-20240327042549-bc490516bd1a/projects/nodes/pkg/model/gen/max.go (about) 1 // File generated by nodegen. DO NOT EDIT. 2 package gen 3 4 import ( 5 "fmt" 6 "time" 7 8 "github.com/wcharczuk/go-incr" 9 "go.charczuk.com/projects/nodes/pkg/funcs" 10 "go.charczuk.com/projects/nodes/pkg/incrutil" 11 "go.charczuk.com/projects/nodes/pkg/types" 12 ) 13 14 func MaxForNode(graph *incr.Graph, n *types.Node) (output incr.INode, err error) { 15 switch n.Metadata.InputType { 16 case "[]float64": 17 switch n.Metadata.OutputType { 18 case "float64": 19 output = incrutil.MapN(graph, funcs.MaxMany[float64]) 20 return 21 default: 22 err = fmt.Errorf("invalid max output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 23 return 24 } 25 26 case "[]int64": 27 switch n.Metadata.OutputType { 28 case "int64": 29 output = incrutil.MapN(graph, funcs.MaxMany[int64]) 30 return 31 default: 32 err = fmt.Errorf("invalid max output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 33 return 34 } 35 36 case "[]duration": 37 switch n.Metadata.OutputType { 38 case "duration": 39 output = incrutil.MapN(graph, funcs.MaxMany[time.Duration]) 40 return 41 default: 42 err = fmt.Errorf("invalid max output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 43 return 44 } 45 46 case "float64": 47 switch n.Metadata.OutputType { 48 case "float64": 49 output = incrutil.MapN(graph, funcs.Max[float64]) 50 return 51 default: 52 err = fmt.Errorf("invalid max output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 53 return 54 } 55 56 case "int64": 57 switch n.Metadata.OutputType { 58 case "int64": 59 output = incrutil.MapN(graph, funcs.Max[int64]) 60 return 61 default: 62 err = fmt.Errorf("invalid max output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 63 return 64 } 65 66 case "duration": 67 switch n.Metadata.OutputType { 68 case "duration": 69 output = incrutil.MapN(graph, funcs.Max[time.Duration]) 70 return 71 default: 72 err = fmt.Errorf("invalid max output type %v for input type %v", n.Metadata.OutputType, n.Metadata.InputType) 73 return 74 } 75 76 default: 77 err = fmt.Errorf("invalid max input type %v", n.Metadata.InputType) 78 return 79 } 80 }