LiteralUtils { @CheckForNull public static Integer intLiteralValue(ExpressionTree expression) { if (expression.is(Tree.Kind.INT_LITERAL)) { return intLiteralValue((LiteralTree) expression); } if (expression.is(Tree.Kind.UNARY_MINUS, Tree.Kind.UNARY_PLUS)) { UnaryExpressionTree unaryExp = (UnaryExpressionTree) expression; Integer subExpressionIntValue = intLiteralValue(unaryExp.expression()); return expression.is(Tree.Kind.UNARY_MINUS) ? minus(subExpressionIntValue) : subExpressionIntValue; } return null; } private  LiteralUtils(); @CheckForNull static Integer intLiteralValue(ExpressionTree expression); @CheckForNull static Long longLiteralValue(ExpressionTree tree); static boolean isEmptyString(Tree tree); static boolean is0xff(ExpressionTree expression); static String trimQuotes(String value); static boolean isTextBlock(String value); static String trimLongSuffix(String longString); static boolean hasValue(Tree tree, String expectedValue); static boolean isTrue(Tree tree); static boolean isFalse(Tree tree); static boolean isZero(ExpressionTree tree); static boolean isOne(ExpressionTree tree); static boolean isNegOne(ExpressionTree tree);  }
@Test void testLargeBinary() { assertThat(LiteralUtils.intLiteralValue(getIntLiteral("0b1111_1111_1111_1111_0000_0000_0000_0000"))).isEqualTo(0b1111_1111_1111_1111_0000_0000_0000_0000); assertThat(LiteralUtils.intLiteralValue(getIntLiteral("0b0111_1111_1111_1111_0000_0000_0000_0000"))).isEqualTo(0b0111_1111_1111_1111_0000_0000_0000_0000); assertThat(LiteralUtils.intLiteralValue(getIntLiteral("0b0000_1111_1111_1111_1111_0000_0000_0000_0000"))).isEqualTo(0b0000_1111_1111_1111_1111_0000_0000_0000_0000); assertThat(LiteralUtils.intLiteralValue(getIntLiteral("0x00FFF0000"))).isEqualTo(0x00FFF0000); assertThat(LiteralUtils.intLiteralValue(getIntLiteral("0xFFFF0000"))).isEqualTo(0xFFFF0000); assertThat(LiteralUtils.intLiteralValue(getIntLiteral("0x7FFF0000"))).isEqualTo(0x7FFF0000); }