/** * <p>Evaluate the given {@code predicate} using {@code value} as input.</p> * * <p>The function throws {@link PreconditionViolationException} if the * predicate is false.</p> * * @param value The value * @param condition The predicate * @param describer A describer for the predicate * @param <T> The type of values * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static <T> T checkPrecondition( final T value, final boolean condition, final Function<T, String> describer) { return innerCheck(value, condition, describer); }
/** * <p>Evaluate the given {@code predicate} using {@code value} as input.</p> * * <p>The function throws {@link PreconditionViolationException} if the * predicate is false.</p> * * @param value The value * @param condition The predicate * @param describer A describer for the predicate * @param <T> The type of values * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static <T> T checkPrecondition( final T value, final boolean condition, final Function<T, String> describer) { return innerCheck(value, condition, describer); }
/** * <p>Evaluate the given {@code predicate} using {@code value} as input.</p> * * <p>The function throws {@link PreconditionViolationException} if the * predicate is false.</p> * * @param value The value * @param predicate The predicate * @param describer A describer for the predicate * @param <T> The type of values * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static <T> T checkPrecondition( final T value, final Predicate<T> predicate, final Function<T, String> describer) { final boolean ok; try { ok = predicate.test(value); } catch (final Throwable e) { throw failed(value, singleViolation(failedPredicate(e))); } return innerCheck(value, ok, describer); }
/** * <p>Evaluate the given {@code predicate} using {@code value} as input.</p> * * <p>The function throws {@link PreconditionViolationException} if the * predicate is false.</p> * * @param value The value * @param predicate The predicate * @param describer A describer for the predicate * @param <T> The type of values * * @return value * * @throws PreconditionViolationException If the predicate is false */ public static <T> T checkPrecondition( final T value, final Predicate<T> predicate, final Function<T, String> describer) { final boolean ok; try { ok = predicate.test(value); } catch (final Throwable e) { throw failed(value, singleViolation(failedPredicate(e))); } return innerCheck(value, ok, describer); }