本文整理汇总了Java中java.lang.annotation.Documented类的典型用法代码示例。如果您正苦于以下问题:Java Documented类的具体用法?Java Documented怎么用?Java Documented使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Documented类属于java.lang.annotation包,在下文中一共展示了Documented类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildTemplateConstraint
import java.lang.annotation.Documented; //导入依赖的package包/类
private JDefinedClass buildTemplateConstraint(String name) {
try {
JDefinedClass tplConstraint = codeModel._class(Config.CFG.getBasePackageName() + ".annot."+name, ClassType.ANNOTATION_TYPE_DECL);
tplConstraint.annotate(Documented.class);
tplConstraint.annotate(Retention.class).param("value", RetentionPolicy.RUNTIME);
tplConstraint.annotate(Target.class).paramArray("value").param(ElementType.TYPE).param(ElementType.ANNOTATION_TYPE).param(ElementType.FIELD).param(ElementType.METHOD);
// Using direct as I don't know how to build default { } with code model
tplConstraint.direct("\n" + " Class<?>[] groups() default {};\n" + " String message() default \"Invalid value\";\n" + " Class<? extends Payload>[] payload() default {};\n");
// Hack to force the import of javax.validation.Payload
tplConstraint.javadoc().addThrows((JClass) codeModel._ref(Payload.class)).add("Force import");
return tplConstraint;
} catch (JClassAlreadyExistsException e) {
throw new RuntimeException("Tried to create an already existing class: " + name, e);
}
}
示例2: verifyAnnotations
import java.lang.annotation.Documented; //导入依赖的package包/类
private void verifyAnnotations(Iterable<? extends AnnotationMirror> annotations,
Set<String> acceptable) {
for (AnnotationMirror mirror : annotations) {
Element annotationElement = mirror.getAnnotationType().asElement();
if (annotationElement.getAnnotation(Documented.class) == null) {
note("Ignoring undocumented annotation: " + mirror.getAnnotationType());
}
verifyTypeAcceptable(mirror.getAnnotationType(), acceptable);
for (AnnotationValue value : mirror.getElementValues().values()) {
verifyAnnotationValue(value, acceptable);
}
}
}
示例3: doTestMetadataForAnnotationClass
import java.lang.annotation.Documented; //导入依赖的package包/类
private void doTestMetadataForAnnotationClass(AnnotationMetadata metadata) {
assertThat(metadata.getClassName(), is(Component.class.getName()));
assertThat(metadata.isInterface(), is(true));
assertThat(metadata.isAnnotation(), is(true));
assertThat(metadata.isAbstract(), is(true));
assertThat(metadata.isConcrete(), is(false));
assertThat(metadata.hasSuperClass(), is(false));
assertThat(metadata.getSuperClassName(), nullValue());
assertThat(metadata.getInterfaceNames().length, is(1));
assertThat(metadata.getInterfaceNames()[0], is(Annotation.class.getName()));
assertThat(metadata.isAnnotated(Documented.class.getName()), is(false));
assertThat(metadata.isAnnotated(Scope.class.getName()), is(false));
assertThat(metadata.isAnnotated(SpecialAttr.class.getName()), is(false));
assertThat(metadata.hasAnnotation(Documented.class.getName()), is(true));
assertThat(metadata.hasAnnotation(Scope.class.getName()), is(false));
assertThat(metadata.hasAnnotation(SpecialAttr.class.getName()), is(false));
assertThat(metadata.getAnnotationTypes().size(), is(3));
}
示例4: getAllReflectionClasses
import java.lang.annotation.Documented; //导入依赖的package包/类
private void getAllReflectionClasses() throws NotFoundException{
//System annotations
addClassIfNotExists(typeOracle.getType(Retention.class.getCanonicalName()), ReflectableHelper.getDefaultSettings(typeOracle));
addClassIfNotExists(typeOracle.getType(Documented.class.getCanonicalName()), ReflectableHelper.getDefaultSettings(typeOracle));
addClassIfNotExists(typeOracle.getType(Inherited.class.getCanonicalName()), ReflectableHelper.getDefaultSettings(typeOracle));
addClassIfNotExists(typeOracle.getType(Target.class.getCanonicalName()), ReflectableHelper.getDefaultSettings(typeOracle));
addClassIfNotExists(typeOracle.getType(Deprecated.class.getCanonicalName()), ReflectableHelper.getDefaultSettings(typeOracle));
//typeOracle.getType("org.lirazs.gbackbone.client.test.reflection.TestReflectionGenerics.TestReflection1");
//=====GWT0.7
for (JClassType classType : typeOracle.getTypes()) {
Reflectable reflectable = GenUtils.getClassTypeAnnotationWithMataAnnotation(classType, Reflectable.class);
if (reflectable != null){
processClass(classType, reflectable);
if (reflectable.assignableClasses()){
for (JClassType type : classType.getSubtypes()){
processClass(type, reflectable);
}
}
}
}
//======end of gwt0.7
}
示例5: testScanOtherPackage
import java.lang.annotation.Documented; //导入依赖的package包/类
@Test
public void testScanOtherPackage() {
//There can't be a class that is annotated with Inject
final DefaultClasspathScanner scanner = new DefaultClasspathScanner(CLASSPATH_SCAN);
Set<Class<?>> classes = scanner.getTypesAnnotatedWith(Resources.class);
assertNotNull(classes);
assertEquals(classes.size(), 0);
classes = scanner.getTypesAnnotatedWith(AnnotationForClasspathScanTest.class);
assertNotNull(classes);
assertEquals(classes.size(), 0);
classes = scanner.getTypesAnnotatedWith(Documented.class);
assertNotNull(classes);
assertEquals(classes.size(), 1);
assertTrue(classes.contains(DocumentAnnotatedClass.class));
}
示例6: user
import java.lang.annotation.Documented; //导入依赖的package包/类
/**
* user operators.
*/
@Test
public void user() {
OperatorEstimator estimator = CompositeOperatorEstimator.builder()
.withUser(Deprecated.class, engine("a"))
.withUser(Documented.class, engine("b"))
.build();
Operator o0 = user(classOf(Deprecated.class));
Operator o1 = user(classOf(Documented.class));
Operator o2 = user(clazz("Unknown"));
OperatorEstimate e0 = perform(context(), estimator, o0);
OperatorEstimate e1 = perform(context(), estimator, o1);
OperatorEstimate e2 = perform(context(), estimator, o2);
assertThat(e0, hasMark("a"));
assertThat(e1, hasMark("b"));
assertThat(e2, hasMark(null));
}
示例7: test_computeDependencies_packageInfo
import java.lang.annotation.Documented; //导入依赖的package包/类
public void test_computeDependencies_packageInfo() {
for (boolean apiOnly : FALSE_TRUE) {
final SortedSet<String> expected = new TreeSet<String>();
//
if (apiOnly) {
} else {
addSlashedName(expected, TestAnno1.class);
addSlashedName(expected, TestAnno2.class);
addSlashedName(expected, Object.class);
// String doesn't make it into the class file,
// only types of other arguments.
addSlashedName(expected, Integer.class);
addSlashedName(expected, RoundingMode.class);
addSlashedName(expected, Documented.class);
}
computeDepsAndCheck(TestAnno1.class.getPackage().getName() + ".package-info", apiOnly, expected);
}
}
示例8: test_computeDependencies_methodCodeStaticInitBlock
import java.lang.annotation.Documented; //导入依赖的package包/类
public void test_computeDependencies_methodCodeStaticInitBlock() {
for (boolean apiOnly : FALSE_TRUE) {
final SortedSet<String> expected = new TreeSet<String>();
//
addSlashedName(expected, Object.class);
//
if (apiOnly) {
} else {
addSlashedName(expected, ClassDepsParserTest.class);
//
if (BUG_JDK_8136419_FIXED) {
addSlashedName(expected, A_TYPE_USE_R_COMPLEX.class);
addSlashedName(expected, Long.class);
addSlashedName(expected, RoundingMode.class);
addSlashedName(expected, Documented.class);
}
addSlashedName(expected, Integer.class);
addSlashedName(expected, MyBlackHole.class);
addSlashedName(expected, RuntimeException.class);
}
computeDepsAndCheck(MyMethodCodeStaticInitBlock.class.getName(), apiOnly, expected);
}
}
示例9: test_computeDependencies_methodCodeInitBlock
import java.lang.annotation.Documented; //导入依赖的package包/类
public void test_computeDependencies_methodCodeInitBlock() {
for (boolean apiOnly : FALSE_TRUE) {
final SortedSet<String> expected = new TreeSet<String>();
//
addSlashedName(expected, Object.class);
//
if (apiOnly) {
} else {
addSlashedName(expected, ClassDepsParserTest.class);
//
if (BUG_JDK_8136419_FIXED) {
addSlashedName(expected, A_TYPE_USE_R_COMPLEX.class);
addSlashedName(expected, Long.class);
addSlashedName(expected, RoundingMode.class);
addSlashedName(expected, Documented.class);
}
addSlashedName(expected, Integer.class);
addSlashedName(expected, MyBlackHole.class);
addSlashedName(expected, RuntimeException.class);
}
computeDepsAndCheck(MyMethodCodeInitBlock.class.getName(), apiOnly, expected);
}
}
示例10: test_computeDependencies_methodCodeConstructor
import java.lang.annotation.Documented; //导入依赖的package包/类
public void test_computeDependencies_methodCodeConstructor() {
for (boolean apiOnly : FALSE_TRUE) {
final SortedSet<String> expected = new TreeSet<String>();
//
addSlashedName(expected, Object.class);
//
if (apiOnly) {
} else {
addSlashedName(expected, ClassDepsParserTest.class);
//
addSlashedName(expected, A_TYPE_USE_R_COMPLEX.class);
addSlashedName(expected, Long.class);
addSlashedName(expected, RoundingMode.class);
addSlashedName(expected, Documented.class);
addSlashedName(expected, Integer.class);
addSlashedName(expected, MyBlackHole.class);
addSlashedName(expected, RuntimeException.class);
}
computeDepsAndCheck(MyMethodCodeConstructor.class.getName(), apiOnly, expected);
}
}
示例11: test_computeDependencies_methodCodeNonGen
import java.lang.annotation.Documented; //导入依赖的package包/类
public void test_computeDependencies_methodCodeNonGen() {
for (boolean apiOnly : FALSE_TRUE) {
final SortedSet<String> expected = new TreeSet<String>();
//
addSlashedName(expected, Object.class);
//
if (apiOnly) {
} else {
addSlashedName(expected, ClassDepsParserTest.class);
//
addSlashedName(expected, A_TYPE_USE_R_COMPLEX.class);
addSlashedName(expected, Long.class);
addSlashedName(expected, RoundingMode.class);
addSlashedName(expected, Documented.class);
addSlashedName(expected, Integer.class);
addSlashedName(expected, MyBlackHole.class);
addSlashedName(expected, RuntimeException.class);
}
computeDepsAndCheck(MyMethodCodeNonGen.class.getName(), apiOnly, expected);
}
}
示例12: test_computeDependencies_methodCodeGenStrict
import java.lang.annotation.Documented; //导入依赖的package包/类
public void test_computeDependencies_methodCodeGenStrict() {
for (boolean apiOnly : FALSE_TRUE) {
final SortedSet<String> expected = new TreeSet<String>();
//
addSlashedName(expected, Object.class);
//
if (apiOnly) {
} else {
addSlashedName(expected, ClassDepsParserTest.class);
//
addSlashedName(expected, A_TYPE_USE_R_COMPLEX.class);
addSlashedName(expected, Long.class);
addSlashedName(expected, RoundingMode.class);
addSlashedName(expected, Documented.class);
addSlashedName(expected, Comparable.class);
addSlashedName(expected, MyBlackHole.class);
addSlashedName(expected, RuntimeException.class);
}
computeDepsAndCheck(MyMethodCodeGenStrict.class.getName(), apiOnly, expected);
}
}
示例13: test_computeDependencies_methodCodeGenLoose
import java.lang.annotation.Documented; //导入依赖的package包/类
public void test_computeDependencies_methodCodeGenLoose() {
for (boolean apiOnly : FALSE_TRUE) {
final SortedSet<String> expected = new TreeSet<String>();
//
addSlashedName(expected, Object.class);
//
if (apiOnly) {
} else {
addSlashedName(expected, ClassDepsParserTest.class);
//
addSlashedName(expected, A_TYPE_USE_R_COMPLEX.class);
addSlashedName(expected, Long.class);
addSlashedName(expected, RoundingMode.class);
addSlashedName(expected, Documented.class);
addSlashedName(expected, Comparable.class);
addSlashedName(expected, MyBlackHole.class);
addSlashedName(expected, RuntimeException.class);
}
computeDepsAndCheck(MyMethodCodeGenLoose.class.getName(), apiOnly, expected);
}
}
示例14: test_isAnnotationPresent_Cla
import java.lang.annotation.Documented; //导入依赖的package包/类
/**
*
*/
public void test_isAnnotationPresent_Cla() {
class e {};
assertFalse("zzz annotation is not presented for e class!",
e.class.isAnnotationPresent(zzz.class));
assertFalse("zzz annotation is not presented for zzz class!",
zzz.class.isAnnotationPresent(zzz.class));
assertTrue("Target annotation is presented for zzz class!",
zzz.class.isAnnotationPresent(java.lang.annotation
.Target.class));
assertTrue("Documented annotation is presented for zzz class!",
zzz.class.isAnnotationPresent(java.lang.annotation
.Documented.class));
assertTrue("Retention annotation is presented for zzz class!",
zzz.class.isAnnotationPresent(java.lang.annotation
.Retention.class));
}
示例15: test_getAnnotation_Cla
import java.lang.annotation.Documented; //导入依赖的package包/类
/**
*
*/
public void test_getAnnotation_Cla() {
class e {};
assertNull("zzz annotation is not presented in e class!",
e.class.getAnnotation(zzz.class));
assertNull("zzz annotation is not presented in zzz class!",
zzz.class.getAnnotation(zzz.class));
assertFalse("Target annotation is presented in zzz class!",
zzz.class.getAnnotation(java.lang.annotation.Target.class)
.toString().indexOf("java.lang.annotation.Target") == -1);
assertFalse("Documented annotation is presented in zzz class!",
zzz.class.getAnnotation(java.lang.annotation.Documented.class)
.toString().indexOf("java.lang.annotation.Documented") == -1);
assertFalse("Retention annotation is presented in zzz class!",
zzz.class.getAnnotation(java.lang.annotation.Retention.class)
.toString().indexOf("java.lang.annotation.Retention") == -1);
}