I'm building a simulator which parses some events from
STDIN and "runs" them. My background is mostly functional programming these days, so it seemed natural to do something like this:
data Event = Thing1 String Int | Thing2 Int | Thing3 String String Int Parse :: String -> [Event] Simulate :: [Event] -> [Result]
where simulate would be
case event of Thing1 a b => compute for thing one | Thing2 a => compute for thing two
etc. What is the idiomatic way to do this sort of thing in Java? Googling has pointed me in the direction of nested classes and the visitor pattern, but that seems rather heavyweight in my attempt. Type erasure seems to be fighting me, hard. Could you show me an outline of what that would look like done correctly?