/** * Executes example. * * @param args Command line arguments, none required. */ public static void main(String[] args) { // Typedefs: // --------- // G -> GridFactory // CI1 -> GridInClosure // CO -> GridOutClosure // CA -> GridAbsClosure // F -> GridFunc GridEither<String, Integer> either = getValue(false); if (either.isLeft()) X.println("Left: " + either.left()); else X.println("Right: " + either.right()); }
/** * Method returns either {@code String} or {@code Integer} value. * * @param left Whether return left or right value. * @return Either left or right value. */ private static GridEither<String, Integer> getValue(boolean left) { return left ? GridEither.<String, Integer>makeLeft("left") : GridEither.<String, Integer>makeRight(20); }