當前位置: 首頁>>代碼示例>>Java>>正文


Java Implements類代碼示例

本文整理匯總了Java中org.robolectric.annotation.Implements的典型用法代碼示例。如果您正苦於以下問題:Java Implements類的具體用法?Java Implements怎麽用?Java Implements使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Implements類屬於org.robolectric.annotation包,在下文中一共展示了Implements類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: reset

import org.robolectric.annotation.Implements; //導入依賴的package包/類
public static void reset(Config config) {
  Robolectric.application = null;
  Robolectric.packageManager = null;
  Robolectric.activityThread = null;

  ShadowLooper.resetThreadLoopers();
  ShadowChoreographer.resetThreadLoopers();

  List<Class<?>> klasses = Lists.newArrayList();
  klasses.addAll(Arrays.asList(Robolectric.DEFAULT_SHADOW_CLASSES));
  klasses.addAll(Arrays.asList(config.shadows()));

  for (Class<?> klass : klasses) {
    if (klass.getAnnotation(Implements.class).resetStaticState()) {
      staticMethod("reset").in(klass).invoke();
    }
  }
}
 
開發者ID:qx,項目名稱:FullRobolectricTestSample,代碼行數:19,代碼來源:Robolectric.java

示例2: getShadowedClass

import org.robolectric.annotation.Implements; //導入依賴的package包/類
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);
    }
  }
}
 
開發者ID:qx,項目名稱:FullRobolectricTestSample,代碼行數:22,代碼來源:ShadowWrangler.java

示例3: verifyClass

import org.robolectric.annotation.Implements; //導入依賴的package包/類
private void verifyClass(final Class<?> shadowClass) {
  Implements annotation = shadowClass.getAnnotation(Implements.class);
  Class implementedClass = annotation.value();
  if (implementedClass.getName().equals(Robolectric.Anything.class.getName())) return;

  try {
    shadowClass.getConstructor(implementedClass);
  } catch (NoSuchMethodException e) {
    try {
      shadowClass.getConstructor();
    } catch (NoSuchMethodException e1) {
      mismatches.add("Missing constructor for " + shadowClass.getSimpleName());
    }
  }


  String expectedName = ShadowMap.convertToShadowName(implementedClass.getName());
  if (!shadowClass.getName().equals(expectedName)) {
    mismatches.add("Shadow class " + shadowClass.getName() + " didn't have the expected name, should be " + expectedName);
  }

  for (Method shadowMethod : shadowClass.getDeclaredMethods()) {
    verifyMethod(implementedClass, shadowMethod);
  }
}
 
開發者ID:qx,項目名稱:FullRobolectricTestSample,代碼行數:26,代碼來源:RobolectricWiringTest.java

示例4: getShadowInfo

import org.robolectric.annotation.Implements; //導入依賴的package包/類
private static ShadowInfo getShadowInfo(Class<?> shadowClass) {
  Implements implementsAnnotation = shadowClass.getAnnotation(Implements.class);
  if (implementsAnnotation == null) {
    throw new IllegalArgumentException(shadowClass + " is not annotated with @Implements");
  }

  String className = implementsAnnotation.className();
  try {
    if (className.isEmpty()) {
      className = implementsAnnotation.value().getName();
    }
    ShadowConfig shadowConfig = createShadowConfig(shadowClass.getName(),
        implementsAnnotation.callThroughByDefault(),
        implementsAnnotation.inheritImplementationMethods(),
        implementsAnnotation.looseSignatures());
    return new ShadowInfo(className, shadowConfig);
  } catch (TypeNotPresentException typeLoadingException) {
    String unloadableClassName = shadowClass.getSimpleName();
    if (typeLoadingException.typeName().startsWith("com.google.android.maps")) {
      warnAbout(unloadableClassName);
      return null;
    } else if (isIgnorableClassLoadingException(typeLoadingException)) {
      //this allows users of the robolectric.jar file to use the non-Google APIs version of the api
      warnAbout(unloadableClassName);
    } else {
      throw typeLoadingException;
    }
  }
  return null;
}
 
開發者ID:qx,項目名稱:FullRobolectricTestSample,代碼行數:31,代碼來源:ShadowMap.java


注:本文中的org.robolectric.annotation.Implements類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。