public static boolean isRepresentedAsNative(String className) { return FluentIterable.from(Arrays.asList(DispatchType.values())) .transform( new Function<DispatchType, String>() { @Override public String apply(DispatchType dispatchType) { return dispatchType.getclassName(); } }) .filter(Predicates.notNull()) .toSet() .contains(className); }
/** * Creates a multi expression from a list of expressions, removing expressions that do not have * side effects if possible. */ public static JExpression createOptimizedMultiExpression( boolean ignoringResult, List<JExpression> expressions) { int numberOfExpressions = expressions.size(); JExpression result = expressions.get(numberOfExpressions - 1); numberOfExpressions = expressions.size(); if (numberOfExpressions == 0) { return new JMultiExpression(SourceOrigin.UNKNOWN); } expressions = Lists.newArrayList( Collections2.filter( expressions.subList(0, numberOfExpressions - 1), Predicates.and( Predicates.notNull(), new Predicate<JExpression>() { @Override public boolean apply(JExpression expression) { return expression.hasSideEffects(); } }))); if (result != null && (!ignoringResult || result.hasSideEffects())) { expressions.add(result); } if (expressions.size() == 1) { // Do not create a multi expression if it consists only of the result. return expressions.iterator().next(); } SourceInfo info = expressions.size() > 0 ? expressions.get(0).getSourceInfo() : SourceOrigin.UNKNOWN; return new JMultiExpression(info, expressions); }