本文整理了Java中org.robolectric.annotation.Implements.value()
方法的一些代码示例,展示了Implements.value()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Implements.value()
方法的具体详情如下:
包路径:org.robolectric.annotation.Implements
类名称: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));
}
内容来源于网络,如有侵权,请联系作者删除!