Usage { public boolean hasReturn(List<Statement> statements) { boolean hasReturn = false; for (Statement statement : statements) { hasReturn = hasReturn || statement.match(new Statement.MatchBlockWithDefault<Boolean>() { @Override public Boolean _case(Return x) { return true; } @Override public Boolean _default(Statement x) { return false; } }); } return hasReturn; }  Function sampleFunction(); Set<Integer> expressionLiterals(Expression expression); boolean hasReturn(List<Statement> statements);  }
@Test public void testHasReturn() { final List<Statement> noReturn = Arrays.asList(_Declaration(_Int(), "Foo", _IntLiteral(2)), _Assignment("foo", _IntLiteral(3))); assertFalse("Got the wrong answer from a list with no returns", usage.hasReturn(noReturn)); final List<Statement> hasReturn = new ArrayList<Statement>(noReturn); hasReturn.add(_Return(_LongLiteral(3))); assertTrue("Got wrong answer from a list with a return", usage.hasReturn(hasReturn)); }