org.robolectric.annotation.Implements.value()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(3.1k)|赞(0)|评价(0)|浏览(111)

本文整理了Java中org.robolectric.annotation.Implements.value()方法的一些代码示例,展示了Implements.value()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Implements.value()方法的具体详情如下:
包路径:org.robolectric.annotation.Implements
类名称:Implements
方法名:value

Implements.value介绍

暂无

代码示例

代码示例来源:origin: robolectric/robolectric

static ShadowInfo obtainShadowInfo(Class<?> clazz, boolean mayBeNonShadow) {
 Implements annotation = clazz.getAnnotation(Implements.class);
 if (annotation == null) {
  if (mayBeNonShadow) {
   return null;
  } else {
   throw new IllegalArgumentException(clazz + " is not annotated with @Implements");
  }
 }
 String className = annotation.className();
 if (className.isEmpty()) {
  className = annotation.value().getName();
 }
 return new ShadowInfo(className, clazz.getName(), annotation);
}

代码示例来源:origin: robolectric/robolectric

public static void withConfig(InstrumentationConfiguration.Builder builder, Config config) {
 for (Class<?> clazz : config.shadows()) {
  Implements annotation = clazz.getAnnotation(Implements.class);
  if (annotation == null) {
   throw new IllegalArgumentException(clazz + " is not annotated with @Implements");
  }
  String className = annotation.className();
  if (className.isEmpty()) {
   className = annotation.value().getName();
  }
  if (!className.isEmpty()) {
   builder.addInstrumentedClass(className);
  }
 }
 for (String packageName : config.instrumentedPackages()) {
  builder.addInstrumentedPackage(packageName);
 }
}

代码示例来源:origin: org.robolectric/robolectric

public static void withConfig(InstrumentationConfiguration.Builder builder, Config config) {
 for (Class<?> clazz : config.shadows()) {
  Implements annotation = clazz.getAnnotation(Implements.class);
  if (annotation == null) {
   throw new IllegalArgumentException(clazz + " is not annotated with @Implements");
  }
  String className = annotation.className();
  if (className.isEmpty()) {
   className = annotation.value().getName();
  }
  if (!className.isEmpty()) {
   builder.addInstrumentedClass(className);
  }
 }
 for (String packageName : config.instrumentedPackages()) {
  builder.addInstrumentedPackage(packageName);
 }
}

代码示例来源:origin: org.robolectric/robolectric-sandbox

private Class<?> getShadowedClass(Method shadowMethod) {
 Class<?> shadowingClass = shadowMethod.getDeclaringClass();
 if (shadowingClass.equals(Object.class)) {
  return Object.class;
 }
 Implements implementsAnnotation = shadowingClass.getAnnotation(Implements.class);
 if (implementsAnnotation == null) {
  throw new RuntimeException(shadowingClass + " has no @" + Implements.class.getSimpleName() + " annotation");
 }
 String shadowedClassName = implementsAnnotation.className();
 if (shadowedClassName.isEmpty()) {
  return implementsAnnotation.value();
 } else {
  try {
   return shadowingClass.getClassLoader().loadClass(shadowedClassName);
  } catch (ClassNotFoundException e) {
   throw new RuntimeException(e);
  }
 }
}

代码示例来源:origin: org.robolectric/robolectric-sandbox

public static ShadowInfo getShadowInfo(Class<?> clazz) {
 Implements annotation = clazz.getAnnotation(Implements.class);
 if (annotation == null) {
  throw new IllegalArgumentException(clazz + " is not annotated with @Implements");
 }
 String className = annotation.className();
 if (className.isEmpty()) {
  className = annotation.value().getName();
 }
 return new ShadowInfo(className, new ShadowConfig(clazz.getName(), annotation));
}

相关文章