default annotation for method of an interface

278 Views Asked by At

I have an interface:

public interface PermissionCallback {
    @SuppressLint("MissingPermission")
    void grantedPermission(String permission);

    void deniedPermission(String permission);
}

and I want when I implement it, by default add @SuppressLint("MissingPermission") on overridden method. like this:

@SuppressLint("MissingPermission")
@Override
public void grantedPermission(String permission) {
   //...
}

Can anyone tell me, why it doesn't add?

1

There are 1 best solutions below

0
itsjwala On BEST ANSWER

Annotation on methods aren't inherited as properly explained in this answer though if you want to check if the method have the annotation you can explicity write a custom function that will do it for you, also well explained here