本文整理匯總了Java中java.lang.annotation.Annotation.toString方法的典型用法代碼示例。如果您正苦於以下問題:Java Annotation.toString方法的具體用法?Java Annotation.toString怎麽用?Java Annotation.toString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.lang.annotation.Annotation
的用法示例。
在下文中一共展示了Annotation.toString方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: prepareBundle
import java.lang.annotation.Annotation; //導入方法依賴的package包/類
private Bundle prepareBundle(Object[] args) {
Bundle bundle = new Bundle();
int paramCount = parameterTypes.length;
if (parameterTypes != null && paramCount > 0){
for (int i = 0; i < paramCount; i++) {
String key;
Annotation[] paramAnnotations = parameterAnnotationsArray[i];
for (Annotation anno: paramAnnotations) {
if (anno instanceof Key){
key = ((Key) anno).value();
handleParams(bundle, key, parameterTypes[i], args[i]);
}else if(anno instanceof FieldMap){
}else{
throw new IllegalStateException("不支持的參數注解: " + anno.toString() );
}
}
}
}
return bundle;
}
示例2: parseMethodAnnotation
import java.lang.annotation.Annotation; //導入方法依賴的package包/類
private void parseMethodAnnotation(Annotation annotation) {
if (annotation instanceof Scheme){
scheme = ((Scheme) annotation).value();
}else if (annotation instanceof TargetName){
className = ((TargetName) annotation).value();
}else if(annotation instanceof TargetClass){
className = ((TargetClass) annotation).value().getName();
}else if(annotation instanceof RequestCode){
requestCode = ((RequestCode) annotation).value();
}else if(annotation instanceof Flags){
flags |= ((Flags) annotation).value();
}else{
throw new IllegalStateException("不支持的方法注解: " + annotation.toString() );
}
}
示例3: getAnnotationName
import java.lang.annotation.Annotation; //導入方法依賴的package包/類
String getAnnotationName() {
Annotation annotation = annotationStrategy.getAnnotation();
if (annotation != null) {
return annotation.toString();
}
// not test-covered
return annotationStrategy.getAnnotationType().toString();
}
示例4: newSetBinder
import java.lang.annotation.Annotation; //導入方法依賴的package包/類
/**
* Returns a new multibinder that collects instances of {@code type} in a {@link Set} that is
* itself bound with {@code annotation}.
*/
public static <T> Multibinder<T> newSetBinder(
Binder binder, TypeLiteral<T> type, Annotation annotation) {
binder = binder.skipSources(RealMultibinder.class, Multibinder.class);
RealMultibinder<T> result = new RealMultibinder<>(binder, type, annotation.toString(),
Key.get(Multibinder.<T>setOf(type), annotation));
binder.install(result);
return result;
}
示例5: getAnnotationName
import java.lang.annotation.Annotation; //導入方法依賴的package包/類
String getAnnotationName() {
Annotation annotation = annotationStrategy.getAnnotation();
if (annotation != null) {
return annotation.toString();
}
// not test-covered
return annotationStrategy.getAnnotationType().toString();
}
示例6: compareArrVals
import java.lang.annotation.Annotation; //導入方法依賴的package包/類
private boolean compareArrVals(Annotation[] actualAnnos, String[] expectedAnnos) {
// Look if test case was run.
if (actualAnnos == specialAnnoArray) {
return false; // no testcase matches
}
if (actualAnnos.length != expectedAnnos.length) {
System.out.println("Length not same. "
+ " actualAnnos length = " + actualAnnos.length
+ " expectedAnnos length = " + expectedAnnos.length);
printArrContents(actualAnnos);
printArrContents(expectedAnnos);
return false;
} else {
int i = 0;
String[] actualArr = new String[actualAnnos.length];
for (Annotation a : actualAnnos) {
actualArr[i++] = a.toString();
}
List<String> actualList = Arrays.asList(actualArr);
List<String> expectedList = Arrays.asList(expectedAnnos);
if (!actualList.containsAll(expectedList)) {
System.out.println("Array values are not same");
printArrContents(actualAnnos);
printArrContents(expectedAnnos);
return false;
}
}
return true;
}
示例7: compareAnnotations
import java.lang.annotation.Annotation; //導入方法依賴的package包/類
private static boolean compareAnnotations(Annotation[] actualAnnos,
String[] expectedAnnos) {
boolean compOrder = false;
// Length is different
if (actualAnnos.length != expectedAnnos.length) {
error("Length not same, Actual length = " + actualAnnos.length
+ " Expected length = " + expectedAnnos.length);
printArrContents(actualAnnos);
printArrContents(expectedAnnos);
return false;
} else {
int i = 0;
// Length is same and 0
if (actualAnnos.length == 0) {
// Expected/actual lengths already checked for
// equality; no more checks do to
return true;
}
// Expected annotation should be NULL
if (actualAnnos[0] == null) {
if (expectedAnnos[0].equals("NULL")) {
debugPrint("Arr values are NULL as expected");
return true;
} else {
error("Array values are not NULL");
printArrContents(actualAnnos);
printArrContents(expectedAnnos);
return false;
}
}
// Lengths are same, compare array contents
String[] actualArr = new String[actualAnnos.length];
for (Annotation a : actualAnnos) {
if (a.annotationType().getSimpleName().contains("Expected"))
actualArr[i++] = a.annotationType().getSimpleName();
else if (a.annotationType().getName().contains(TESTPKG)) {
String replaced = a.toString().replaceAll(Pattern.quote("testpkg."),"");
actualArr[i++] = replaced;
} else
actualArr[i++] = a.toString();
}
List<String> actualList = new ArrayList<String>(Arrays.asList(actualArr));
List<String> expectedList = new ArrayList<String>(Arrays.asList(expectedAnnos));
if (!actualList.containsAll(expectedList)) {
error("Array values are not same");
printArrContents(actualAnnos);
printArrContents(expectedAnnos);
return false;
} else {
debugPrint("Arr values are same as expected");
if (CHECKORDERING) {
debugPrint("Checking if annotation ordering is as expected..");
compOrder = compareOrdering(actualList, expectedList);
if (compOrder)
debugPrint("Arr values ordering is as expected");
else
error("Arr values ordering is not as expected! actual values: "
+ actualList + " expected values: " + expectedList);
} else
compOrder = true;
}
}
return compOrder;
}