Home | History | Annotate | Download | only in annotation
      1 package org.robolectric.annotation;
      2 
      3 import java.lang.annotation.Documented;
      4 import java.lang.annotation.ElementType;
      5 import java.lang.annotation.Retention;
      6 import java.lang.annotation.RetentionPolicy;
      7 import java.lang.annotation.Target;
      8 import org.robolectric.shadow.api.ShadowPicker;
      9 
     10 /**
     11  * Indicates that a class declaration is intended to shadow an Android class declaration.
     12  * The Robolectric runtime searches classes with this annotation for methods with the
     13  * {@link Implementation} annotation and calls them in place of the methods on the Android
     14  * class.
     15  */
     16 @Documented
     17 @Retention(RetentionPolicy.RUNTIME)
     18 @Target({ElementType.TYPE})
     19 public @interface Implements {
     20 
     21   /**
     22    * The Android class to be shadowed.
     23    *
     24    * @return Android class to shadow.
     25    */
     26   Class<?> value() default void.class;
     27 
     28   /**
     29    * Android class name (if the Class object is not accessible).
     30    *
     31    * @return Android class name.
     32    */
     33   String className() default "";
     34 
     35   /**
     36    * Denotes that this type exists in the public Android SDK. When this value is true, the
     37    * annotation processor will generate a shadowOf method.
     38    *
     39    * @return True if the type is exposed in the Android SDK.
     40    */
     41   boolean isInAndroidSdk() default true;
     42 
     43   /**
     44    * If true, Robolectric will invoke the actual Android code for any method that isn't shadowed.
     45    *
     46    * @return True to invoke the underlying method.
     47    */
     48   boolean callThroughByDefault() default true;
     49 
     50   /**
     51    * If true, when an exact method signature match isn't found, Robolectric will look for a method
     52    * with the same name but with all argument types replaced with java.lang.Object.
     53    *
     54    * @return True to disable strict signature matching.
     55    */
     56   boolean looseSignatures() default false;
     57 
     58   /**
     59    * If specified, the shadow class will be applied only for this SDK or greater.
     60    */
     61   int minSdk() default -1;
     62 
     63   /**
     64    * If specified, the shadow class will be applied only for this SDK or lesser.
     65    */
     66   int maxSdk() default -1;
     67 
     68   /**
     69    * If specified, the `picker` will be instantiated and called from within the newly-created
     70    * Robolectric classloader. All shadow classes implementing the same Android class must use
     71    * the same {@link ShadowPicker}.
     72    */
     73   Class<? extends ShadowPicker<?>> shadowPicker() default DefaultShadowPicker.class;
     74 
     75   interface DefaultShadowPicker extends ShadowPicker<Object> {
     76   }
     77 }
     78