Annotation Type Implementation


@Documented @Retention(RUNTIME) @Target(METHOD) public @interface Implementation
Indicates that a method declaration is intended to shadow a method with the same signature on the associated Android class.
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    int
    The annotated shadow method will be invoked only for the specified SDK or lesser.
    @Nullable String
    The implemented method name.
    int
    The annotated shadow method will be invoked only for the specified SDK or greater.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final int
     
  • Field Details

  • Element Details

    • minSdk

      int minSdk
      The annotated shadow method will be invoked only for the specified SDK or greater.
      Default:
      -1
    • maxSdk

      int maxSdk
      The annotated shadow method will be invoked only for the specified SDK or lesser.
      Default:
      -1
    • methodName

      @Nullable String methodName
      The implemented method name.

      Sometimes internal methods return different types for different SDKs. It's safe because these methods are internal/private methods, not public methods. To support different return types of a method for different SDKs, we often use looseSignature method, although all return types are common types like bool and int. This field/property can be used to fix this issue by using different real methods for different SDKs.

      Returns:
      The expected implemented method name. If it is empty/null, the Robolectric will uses the method's name that marked by @Implementation as the implemented method name.
      Default:
      ""