当前位置: 首页>>代码示例>>Java>>正文


Java Annotation.toString方法代码示例

本文整理汇总了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;
}
 
开发者ID:seasonfif,项目名称:SwiftModule,代码行数:22,代码来源:IntentMethod.java

示例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() );
  }
}
 
开发者ID:seasonfif,项目名称:SwiftModule,代码行数:22,代码来源:IntentMethod.java

示例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();
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:10,代码来源:Key.java

示例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;
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:13,代码来源:Multibinder.java

示例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();
}
 
开发者ID:maetrive,项目名称:businessworks,代码行数:10,代码来源:Key.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:31,代码来源:ElementRepAnnoTester.java

示例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;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:66,代码来源:ReflectionTest.java


注:本文中的java.lang.annotation.Annotation.toString方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。