cryptomator / integrations-api

API for optional services, such as system keychain integrations
GNU Affero General Public License v3.0
12 stars 4 forks source link

Filter service loading candidates using new `@CheckAvailability` annotation #8

Closed overheadhunter closed 2 years ago

overheadhunter commented 2 years ago

Allows annotating any number of no-arg boolean methods in a service implementation with @CheckAvailability.

If the annotation is present on the type as well as at least one method, the method will be invoked to let the service decide itself, whether it is available.

Should the method be static, the service will not even be instantiated.

@CheckAvailability
public class FooImpl implements FooService {

    @CheckAvailability
    public static boolean isSupported() {
        return "enabled".equals(System.getProperty("plugin.status"));
    }

}