So you write a function that uses the visitor.
class You { static <X> String stringOne(OneOrNone<X> o) { return o.visit(new OneOrNoneVisitor<String>() { public <T> String visit(One<T> o) { return "got it! " + o.one(); } public <T> String visit(None<T> n) { return "don't got one"; } }); } }
We are effectively destructuring into one of two parts, where one of those parts contains a value, while the other doesn't.