Java Code Examples for java.lang.annotation.RetentionPolicy#values()
The following examples show how to use
java.lang.annotation.RetentionPolicy#values() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AnnotationDefaultTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public void test() throws TestFailedException { try { String template = getSource(getSourceFile(templateFileName)); for (int i = 0; i < 2; ++i) { for (String repeatable : new String[] {"", "@Repeatable(Container.class)"}) { for (RetentionPolicy policy : RetentionPolicy.values()) { final int finalI = i; Map<String, String> replacements = new HashMap<String, String>(){{ put("%POLICY%", policy.toString()); if (finalI != 0) { put("default.*\n", ";\n"); } put("%REPEATABLE%", repeatable); }}; test(template, replacements, i == 0); } } } } catch (Throwable e) { addFailure(e); } finally { checkStatus(); } }
Example 2
Source File: WrongRetentionDetector.java From dagger-reflect with Apache License 2.0 | 5 votes |
@Nullable private static String getRetentionPolicyForQualifiedName(@NotNull String retentionPolicy) { // Values are same for Kotlin and Java for (RetentionPolicy policy : RetentionPolicy.values()) { final String javaQualifiedName = CLASS_JAVA_RETENTION_POLICY + "." + policy.name(); final String kotlinQualifiedName = CLASS_KOTLIN_RETENTION_POLICY + "." + policy.name(); if (javaQualifiedName.equals(retentionPolicy) || kotlinQualifiedName.equals(retentionPolicy)) { return policy.name(); } } return null; }
Example 3
Source File: ClassMembersTest.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
@DataProvider(name = "retentionPolicyTestCase") public Object[][] retentionPolicyTestCaseGenerator() { List<Object[]> list = new ArrayList<>(); for (RetentionPolicy policy : RetentionPolicy.values()) { list.add(new Object[]{policy}); } return list.toArray(new Object[list.size()][]); }
Example 4
Source File: RetentionPolicyTest.java From j2objc with Apache License 2.0 | 5 votes |
/** * @throws Exception * @tests java.lang.annotation.RetentionPolicy#values() */ @SuppressWarnings("nls") public void test_values() throws Exception { RetentionPolicy[] values = RetentionPolicy.values(); assertTrue(values.length > 1); Arrays.sort(values); assertTrue(Arrays.binarySearch(values, RetentionPolicy.RUNTIME) >= 0); }