aboutsummaryrefslogtreecommitdiff
path: root/annotations/src/main/java/org/robolectric/annotation/Implements.java
blob: 053028e2a0f7269953ed04ee182779a87e1f3c5f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
package org.robolectric.annotation;

import java.lang.annotation.Documented;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import org.robolectric.shadow.api.ShadowPicker;

/**
 * Indicates that a class declaration is intended to shadow an Android class declaration.
 * The Robolectric runtime searches classes with this annotation for methods with the
 * {@link Implementation} annotation and calls them in place of the methods on the Android
 * class.
 */
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface Implements {

  /**
   * The Android class to be shadowed.
   *
   * @return Android class to shadow.
   */
  Class<?> value() default void.class;

  /**
   * Android class name (if the Class object is not accessible).
   *
   * @return Android class name.
   */
  String className() default "";

  /**
   * Denotes that this type exists in the public Android SDK. When this value is true, the
   * annotation processor will generate a shadowOf method.
   *
   * @return True if the type is exposed in the Android SDK.
   */
  boolean isInAndroidSdk() default true;

  /**
   * If true, Robolectric will invoke the actual Android code for any method that isn't shadowed.
   *
   * @return True to invoke the underlying method.
   */
  boolean callThroughByDefault() default true;

  /**
   * If true, when an exact method signature match isn't found, Robolectric will look for a method
   * with the same name but with all argument types replaced with java.lang.Object.
   *
   * @return True to disable strict signature matching.
   */
  boolean looseSignatures() default false;

  /**
   * If specified, the shadow class will be applied only for this SDK or greater.
   */
  int minSdk() default -1;

  /**
   * If specified, the shadow class will be applied only for this SDK or lesser.
   */
  int maxSdk() default -1;

  /**
   * If specified, the `picker` will be instantiated and called from within the newly-created
   * Robolectric classloader. All shadow classes implementing the same Android class must use
   * the same {@link ShadowPicker}.
   */
  Class<? extends ShadowPicker<?>> shadowPicker() default DefaultShadowPicker.class;

  interface DefaultShadowPicker extends ShadowPicker<Object> {
  }
}