本文整理了Java中java.lang.annotation.Annotation.toString()
方法的一些代码示例,展示了Annotation.toString()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Annotation.toString()
方法的具体详情如下:
包路径:java.lang.annotation.Annotation
类名称:Annotation
方法名:toString
[英]Returns a String representation of this annotation. It is not strictly defined what the representation has to look like, but it usually consists of the name of the annotation, preceded by a "@". If the annotation contains field members, their names and values are also included in the result.
[中]返回此批注的字符串表示形式。它没有严格定义表示形式的外观,但它通常由注释的名称组成,前面有一个“@”。如果注释包含字段成员,则其名称和值也将包含在结果中。
代码示例来源:origin: spring-projects/spring-framework
@Override
public String toString() {
return this.annotation.toString();
}
}
代码示例来源:origin: redisson/redisson
@Override
public String toString() {
return annotation.toString();
}
}
代码示例来源:origin: com.google.inject/guice
@Override
public String toString() {
return annotation.toString();
}
}
代码示例来源:origin: com.sun.xml.bind/jaxb-impl
public String toString() {
return core.toString();
}
代码示例来源:origin: com.google.inject/guice
@Override
public String toString() {
String annotationString = annotation.toString();
// Show @Provides w/o the com.google.inject prefix.
if (annotation.annotationType() == Provides.class) {
annotationString = "@Provides";
} else if (annotationString.endsWith("()")) {
// Remove the common "()" suffix if there are no values.
annotationString = annotationString.substring(0, annotationString.length() - 2);
}
return annotationString + " " + StackTraceElements.forMember(method);
}
代码示例来源:origin: spring-projects/spring-loaded
public String format(Annotation[] as) {
List<String> names = new ArrayList<String>();
for (Annotation f : as) {
names.add(f.toString());
}
return sortAndPrintNames(names);
}
代码示例来源:origin: spring-projects/spring-loaded
private String printAnnotation(Annotation a) {
return a.toString();
// StringBuilder buf = new StringBuilder();
// printAnnotationHelper(buf,a);
// return buf.toString();
}
代码示例来源:origin: org.junit.jupiter/junit-jupiter-engine
public Script(Annotation annotation, String engine, String source, String reason) {
this(Preconditions.notNull(annotation, "annotation must not be null").annotationType(), annotation.toString(),
engine, source, reason);
}
代码示例来源:origin: com.sun.xml.bind/jaxb-impl
public final String toString() {
return getAnnotation().toString();
}
}
代码示例来源:origin: com.google.inject/guice
String getAnnotationName() {
Annotation annotation = annotationStrategy.getAnnotation();
if (annotation != null) {
return annotation.toString();
}
// not test-covered
return annotationStrategy.getAnnotationType().toString();
}
代码示例来源:origin: stackoverflow.com
char[] buffer = new char[MAX_TITLE_LENGTH * 2];
GetWindowTextW(GetForegroundWindow(), buffer, MAX_TITLE_LENGTH);
System.out.println("Active window title: " + Native.toString(buffer));
Pointer process = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, false, pointer.getValue());
GetModuleBaseNameW(process, null, buffer, MAX_TITLE_LENGTH);
System.out.println("Active window process: " + Native.toString(buffer));
代码示例来源:origin: stackoverflow.com
import com.sun.jna.Native;
import com.sun.jna.platform.win32.*;
import com.sun.jna.win32.W32APIOptions;
public class ProcessList {
public static void main(String[] args) {
WinNT winNT = (WinNT) Native.loadLibrary(WinNT.class, W32APIOptions.UNICODE_OPTIONS);
WinNT.HANDLE snapshot = winNT.CreateToolhelp32Snapshot(Tlhelp32.TH32CS_SNAPPROCESS, new WinDef.DWORD(0));
Tlhelp32.PROCESSENTRY32.ByReference processEntry = new Tlhelp32.PROCESSENTRY32.ByReference();
while (winNT.Process32Next(snapshot, processEntry)) {
System.out.println(processEntry.th32ProcessID + "\t" + Native.toString(processEntry.szExeFile));
}
winNT.CloseHandle(snapshot);
}
}
代码示例来源:origin: com.google.inject/guice
/**
* Returns the name the binding should use. This is based on the annotation. If the annotation has
* an instance and is not a marker annotation, we ask the annotation for its toString. If it was a
* marker annotation or just an annotation type, we use the annotation's name. Otherwise, the name
* is the empty string.
*/
public static String nameOf(Key<?> key) {
Annotation annotation = key.getAnnotation();
Class<? extends Annotation> annotationType = key.getAnnotationType();
if (annotation != null && !isMarker(annotationType)) {
return key.getAnnotation().toString();
} else if (key.getAnnotationType() != null) {
return "@" + key.getAnnotationType().getName();
} else {
return "";
}
}
}
代码示例来源:origin: stackoverflow.com
byte[] buffer = new byte[1024];
User32.instance.GetWindowTextA(hWnd, buffer, buffer.length);
String title = Native.toString(buffer);
inflList.add(new WindowInfo(hWnd, r, title));
代码示例来源:origin: jersey/jersey
for (Annotation a : invocable.getHandlingMethod().getDeclaredAnnotations()) {
if (null != a.annotationType().getAnnotation(HttpMethod.class)) {
httpMethodAnnotations.add(a.toString());
代码示例来源:origin: jersey/jersey
for (Annotation a : invocable.getHandlingMethod().getDeclaredAnnotations()) {
if (null != a.annotationType().getAnnotation(HttpMethod.class)) {
httpMethodAnnotations.add(a.toString());
代码示例来源:origin: spring-projects/spring-loaded
/**
* Testing that type level annotations are copied to the executor. This loads a different form of the type with a
* second annotation.
*/
@Test
public void typeLevelAnnotations2() {
String t = "executor.A";
TypeRegistry typeRegistry = getTypeRegistry(t);
ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
rtype.loadNewVersion("2", retrieveRename(t, t + "2"));
Class<?> clazz = rtype.getLatestExecutorClass();
Assert.assertEquals(Utils.getExecutorName(t, "2"), clazz.getName());
Annotation[] annos = clazz.getAnnotations();
Assert.assertNotNull(annos);
Assert.assertEquals(2, annos.length);
Set<String> s = new HashSet<String>();
for (Annotation anno : annos) {
s.add(anno.toString());
}
Assert.assertTrue(s.remove("@common.Marker()"));
// Allow for alternate toString() variant
if (!s.remove("@common.Anno(someValue=37, longValue=2, id=abc)")) {
Assert.assertTrue(s.remove("@common.Anno(longValue=2, someValue=37, id=abc)"));
}
Assert.assertEquals(0, s.size());
}
代码示例来源:origin: spring-projects/spring-loaded
@Test
public void methodLevelAnnotationsOnInterfaces2() throws Exception {
String t = "reflection.methodannotations.InterfaceTarget";
TypeRegistry typeRegistry = getTypeRegistry(t);
ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
checkAnnotations(rtype.bytesLoaded, "privMethod()V", "@reflection.AnnoT3(value=Foo)");
reload(rtype, "37");
checkAnnotations(rtype.getLatestExecutorBytes(), "privMethod(Lreflection/methodannotations/InterfaceTarget;)V",
"@reflection.AnnoT3(value=Foo)");
rtype.loadNewVersion("39", retrieveRename(t, t + "002"));
checkAnnotations(rtype.getLatestExecutorBytes(), "privMethod(Lreflection/methodannotations/InterfaceTarget;)V",
"@reflection.AnnoT3(value=Bar)");
Method m = rtype.getLatestExecutorClass().getDeclaredMethod("privMethod", rtype.getClazz());
assertEquals("@reflection.AnnoT3(value=Bar)", m.getAnnotations()[0].toString());
}
代码示例来源:origin: spring-projects/spring-loaded
@Test
public void methodLevelAnnotationsOnInterfaces() throws Exception {
String t = "executor.I";
TypeRegistry typeRegistry = getTypeRegistry(t);
ReloadableType rtype = typeRegistry.addType(t, loadBytesForClass(t));
reload(rtype, "37");
checkAnnotations(rtype.bytesLoaded, "m()V", "@common.Marker()");
checkAnnotations(rtype.bytesLoaded, "m2()V");
checkAnnotations(rtype.getLatestExecutorBytes(), "m(Lexecutor/I;)V", "@common.Marker()");
checkAnnotations(rtype.getLatestExecutorBytes(), "m2(Lexecutor/I;)V");
rtype.loadNewVersion("39", retrieveRename("executor.I", "executor.I2"));
checkAnnotations(rtype.getLatestExecutorBytes(), "m(Lexecutor/I;)V");
checkAnnotations(rtype.getLatestExecutorBytes(), "m2(Lexecutor/I;)V", "@common.Marker()",
"@common.Anno(id=abc)");
Method m = rtype.getLatestExecutorClass().getDeclaredMethod("m2", rtype.getClazz());
assertEquals("@common.Marker()", m.getAnnotations()[0].toString());
assertIsOneOfThese(printAnnotation(m.getAnnotations()[1]), "@common.Anno(someValue=37, longValue=2, id=abc)",
"@common.Anno(longValue=2, someValue=37, id=abc)");
}
代码示例来源:origin: org.elasticsearch/elasticsearch
String getAnnotationName() {
Annotation annotation = annotationStrategy.getAnnotation();
if (annotation != null) {
return annotation.toString();
}
// not test-covered
return annotationStrategy.getAnnotationType().toString();
}
内容来源于网络,如有侵权,请联系作者删除!