Source:
public void testCombinedIntDefAndIntRange ( ) throws java.lang.Exception { assertEquals ( ( "" + ( ( ( ( ( ( ( ( ( "src/test/pkg/X.java:27: Error: Must be one of: X.LENGTH_INDEFINITE, X.LENGTH_SHORT, X.LENGTH_LONG [WrongConstant]\n" + " setDuration(UNRELATED); /// ERROR: Not right intdef, even if it\'s in the right number range\n" ) + " ~~~~~~~~~\n" ) + "src/test/pkg/X.java:28: Error: Must be one of: X.LENGTH_INDEFINITE, X.LENGTH_SHORT, X.LENGTH_LONG or value must be ≥ 10 (was -5) [WrongConstant]\n" ) + " setDuration(-5); // ERROR (not right int def or value\n" ) + " ~~\n" ) + "src/test/pkg/X.java:29: Error: Must be one of: X.LENGTH_INDEFINITE, X.LENGTH_SHORT, X.LENGTH_LONG or value must be ≥ 10 (was 8) [WrongConstant]\n" ) + " setDuration(8); // ERROR (not matching number range)\n" ) + " ~\n" ) + "3 errors, 0 warnings\n" ) ) , lintProject ( getManifestWithPermissions ( 14 , 23 ) , java ( "src/test/pkg/X.java" , ( "" + ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( "\n" + "package test.pkg;\n" ) + "\n" ) + "import android.support.annotation.IntDef;\n" ) + "import android.support.annotation.IntRange;\n" ) + "\n" ) + "import java.lang.annotation.Retention;\n" ) + "import java.lang.annotation.RetentionPolicy;\n" ) + "\n" ) + "@SuppressWarnings({\"UnusedParameters\", \"unused\", \"SpellCheckingInspection\"})\n" ) + "public class X {\n" ) + "\n" ) + " public static final int UNRELATED = 500;\n" ) + "\n" ) + " @IntDef({LENGTH_INDEFINITE, LENGTH_SHORT, LENGTH_LONG})\n" ) + " @IntRange(from = 10)\n" ) + " @Retention(RetentionPolicy.SOURCE)\n" ) + " public @interface Duration {}\n" ) + "\n" ) + " public static final int LENGTH_INDEFINITE = -2;\n" ) + " public static final int LENGTH_SHORT = -1;\n" ) + " public static final int LENGTH_LONG = 0;\n" ) + " public void setDuration(@Duration int duration) {\n" ) + " }\n" ) + "\n" ) + " public void test() {\n" ) + " setDuration(UNRELATED); /// ERROR: Not right intdef, even if it\'s in the right number range\n" ) + " setDuration(-5); // ERROR (not right int def or value\n" ) + " setDuration(8); // ERROR (not matching number range)\n" ) + " setDuration(8000); // OK (@IntRange applies)\n" ) + " setDuration(LENGTH_INDEFINITE); // OK (@IntDef)\n" ) + " setDuration(LENGTH_LONG); // OK (@IntDef)\n" ) + " setDuration(LENGTH_SHORT); // OK (@IntDef)\n" ) + " }\n" ) + "}\n" ) ) ) , copy ( "src/android/support/annotation/IntDef.java.txt" , "src/android/support/annotation/IntDef.java" ) , copy ( "src/android/support/annotation/IntRange.java.txt" , "src/android/support/annotation/IntRange.java" ) ) ) ; }

Target:
public void testCombinedIntDefAndIntRange ( ) throws java.lang.Exception { assertEquals ( ( "" + ( ( ( ( ( ( "src/test/pkg/X.java:28: Error: Must be one of: X.LENGTH_INDEFINITE, X.LENGTH_SHORT, X.LENGTH_LONG or value must be ≥ 10 (was -5) [WrongConstant]\n" + " setDuration(-5); // ERROR (not right int def or value\n" ) + " ~~\n" ) + "src/test/pkg/X.java:29: Error: Must be one of: X.LENGTH_INDEFINITE, X.LENGTH_SHORT, X.LENGTH_LONG or value must be ≥ 10 (was 8) [WrongConstant]\n" ) + " setDuration(8); // ERROR (not matching number range)\n" ) + " ~\n" ) + "2 errors, 0 warnings\n" ) ) , lintProject ( getManifestWithPermissions ( 14 , 23 ) , java ( "src/test/pkg/X.java" , ( "" + ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( ( "\n" + "package test.pkg;\n" ) + "\n" ) + "import android.support.annotation.IntDef;\n" ) + "import android.support.annotation.IntRange;\n" ) + "\n" ) + "import java.lang.annotation.Retention;\n" ) + "import java.lang.annotation.RetentionPolicy;\n" ) + "\n" ) + "@SuppressWarnings({\"UnusedParameters\", \"unused\", \"SpellCheckingInspection\"})\n" ) + "public class X {\n" ) + "\n" ) + " public static final int UNRELATED = 500;\n" ) + "\n" ) + " @IntDef({LENGTH_INDEFINITE, LENGTH_SHORT, LENGTH_LONG})\n" ) + " @IntRange(from = 10)\n" ) + " @Retention(RetentionPolicy.SOURCE)\n" ) + " public @interface Duration {}\n" ) + "\n" ) + " public static final int LENGTH_INDEFINITE = -2;\n" ) + " public static final int LENGTH_SHORT = -1;\n" ) + " public static final int LENGTH_LONG = 0;\n" ) + " public void setDuration(@Duration int duration) {\n" ) + " }\n" ) + "\n" ) + " public void test() {\n" ) + " setDuration(UNRELATED); /// OK within range\n" ) + " setDuration(-5); // ERROR (not right int def or value\n" ) + " setDuration(8); // ERROR (not matching number range)\n" ) + " setDuration(8000); // OK (@IntRange applies)\n" ) + " setDuration(LENGTH_INDEFINITE); // OK (@IntDef)\n" ) + " setDuration(LENGTH_LONG); // OK (@IntDef)\n" ) + " setDuration(LENGTH_SHORT); // OK (@IntDef)\n" ) + " }\n" ) + "}\n" ) ) ) , copy ( "src/android/support/annotation/IntDef.java.txt" , "src/android/support/annotation/IntDef.java" ) , copy ( "src/android/support/annotation/IntRange.java.txt" , "src/android/support/annotation/IntRange.java" ) ) ) ; }