ConditionChecker { @Nullable public static <T> T checkArgument(@Nullable final T argument, final Predicate<T> argumentPredicate) { if (!argumentPredicate.test(argument)) { throw new IllegalArgumentException("The argument is invalid!"); } return argument; } private  ConditionChecker(); static T checkNotNull(@Nullable final T argument); static T checkNotNull(@Nullable final T argument, final String argumentName); static T checkNotEmpty(final T argument, final String argumentName); static T checkNotEmpty(final T argument, final String argumentName); @Nullable static T checkArgument(@Nullable final T argument, final Predicate<T> argumentPredicate); @Nullable static T checkArgument(@Nullable final T argument, final Predicate<T> argumentPredicate,
            final Supplier<String> messageSupplier); static T argumentNotNull(@Nullable final T argument); static T argumentNotNull(@Nullable final T argument, final String argumentName); static T argumentNotEmpty(final T argument); static T argumentNotEmpty(final T argument, final String argumentName); static T argumentNotEmpty(final T argument); static T argumentNotEmpty(final T argument, final String argumentName);  }
@Test(expected = IllegalArgumentException.class) public void checkArgumentWithPredicate() { final String argument = ""; ConditionChecker.checkArgument(argument, s -> !s.isEmpty()); }