Perhaps move this kind of checks into some util class.
e.g. in API module / jar

So you don't have dup code all over the place; api, impl, ...