/** * A specialized version of {@link #checkPostcondition(Object, boolean, * Function)} that does not mention an input value. * * @param condition The predicate * @param message The predicate description * * @throws PostconditionViolationException Iff {@code predicate == false} */ public static void checkPostcondition( final boolean condition, final String message) throws PostconditionViolationException { if (!condition) { throw failed( "<unspecified>", singleViolation(message)); } }
/** * <p>Evaluate the given {@code predicate} using {@code value} as input.</p> * * <p>The function throws {@link PostconditionViolationException} 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 PostconditionViolationException If the predicate is false */ public static <T> T checkPostcondition( final T value, final boolean condition, final Function<T, String> describer) { return innerCheck(value, condition, describer); }
/** * A {@code double} specialized version of {@link #checkPostcondition(Object, * boolean, Function)} * * @param value The value * @param condition The predicate * @param describer The describer of the predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static double checkPostconditionD( final double value, final boolean condition, final DoubleFunction<String> describer) { return innerCheckD(value, condition, describer); }
final T r = constructor.apply(a, b); Postconditions.checkPostcondition( Objects.equals(a.getClass(), r.getClass()), "Scaler must preserve class");
/** * A {@code long} specialized version of {@link #checkPostcondition(Object, * Predicate, Function)} * * @param value The value * @param predicate The predicate * @param describer The describer of the predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static long checkPostconditionL( final long value, final LongPredicate predicate, final LongFunction<String> describer) { final boolean ok; try { ok = predicate.test(value); } catch (final Throwable e) { throw failed( Long.valueOf(value), singleViolation(failedPredicate(e))); } return innerCheckL(value, ok, describer); }
/** * An {@code int} specialized version of {@link #checkPostcondition(Object, * ContractConditionType)}. * * @param value The value * @param predicate The predicate * @param describer The describer for the predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static int checkPostconditionI( final int value, final IntPredicate predicate, final IntFunction<String> describer) { final boolean ok; try { ok = predicate.test(value); } catch (final Throwable e) { throw failed( Integer.valueOf(value), singleViolation(failedPredicate(e))); } return innerCheckI(value, ok, describer); }
/** * A {@code double} specialized version of {@link #checkPostcondition(Object, * Predicate, Function)} * * @param value The value * @param predicate The predicate * @param describer The describer of the predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static double checkPostconditionD( final double value, final DoublePredicate predicate, final DoubleFunction<String> describer) { final boolean ok; try { ok = predicate.test(value); } catch (final Throwable e) { throw failed( Double.valueOf(value), singleViolation(failedPredicate(e))); } return innerCheckD(value, ok, describer); }
/** * <p>Evaluate the given {@code predicate} using {@code value} as input.</p> * * <p>The function throws {@link PostconditionViolationException} 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 PostconditionViolationException If the predicate is false */ public static <T> T checkPostcondition( 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); }
/** * A {@code long} specialized version of {@link #checkPostcondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static long checkPostconditionL( final long value, final ContractLongConditionType condition) throws PostconditionViolationException { return checkPostconditionL( value, condition.predicate(), condition.describer()); }
/** * An {@code int} specialized version of {@link #checkPostcondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static int checkPostconditionI( final int value, final ContractIntConditionType condition) throws PostconditionViolationException { return checkPostconditionI( value, condition.predicate(), condition.describer()); }
/** * A {@code double} specialized version of {@link #checkPostcondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static double checkPostconditionD( final double value, final ContractDoubleConditionType condition) throws PostconditionViolationException { return checkPostconditionD( value, condition.predicate(), condition.describer()); }
/** * An {@code int} specialized version of {@link #checkPostcondition(Object, * boolean, Function)}. * * @param value The value * @param condition The predicate * @param describer The describer for the predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static int checkPostconditionI( final int value, final boolean condition, final IntFunction<String> describer) { return innerCheckI(value, condition, describer); }
/** * A {@code long} specialized version of {@link #checkPostcondition(Object, * Predicate, Function)} * * @param condition The predicate * @param value The value * @param describer The describer of the predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static long checkPostconditionL( final long value, final boolean condition, final LongFunction<String> describer) { return innerCheckL(value, condition, describer); }
/** * <p>Evaluate the given {@code predicate} using {@code value} as input.</p> * * <p>The function throws {@link PostconditionViolationException} if the * predicate is false.</p> * * @param value The value * @param condition The predicate * @param <T> The type of values * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static <T> T checkPostcondition( final T value, final ContractConditionType<T> condition) throws PostconditionViolationException { return checkPostcondition( value, condition.predicate(), condition.describer()); }
/** * A {@code long} specialized version of {@link #checkPostcondition(Object, * Predicate, Function)} * * @param value The value * @param predicate The predicate * @param describer The describer of the predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static long checkPostconditionL( final long value, final LongPredicate predicate, final LongFunction<String> describer) { final boolean ok; try { ok = predicate.test(value); } catch (final Throwable e) { throw failed( Long.valueOf(value), singleViolation(failedPredicate(e))); } return innerCheckL(value, ok, describer); }
/** * An {@code int} specialized version of {@link #checkPostcondition(Object, * ContractConditionType)}. * * @param value The value * @param predicate The predicate * @param describer The describer for the predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static int checkPostconditionI( final int value, final IntPredicate predicate, final IntFunction<String> describer) { final boolean ok; try { ok = predicate.test(value); } catch (final Throwable e) { throw failed( Integer.valueOf(value), singleViolation(failedPredicate(e))); } return innerCheckI(value, ok, describer); }
/** * A {@code double} specialized version of {@link #checkPostcondition(Object, * Predicate, Function)} * * @param value The value * @param predicate The predicate * @param describer The describer of the predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static double checkPostconditionD( final double value, final DoublePredicate predicate, final DoubleFunction<String> describer) { final boolean ok; try { ok = predicate.test(value); } catch (final Throwable e) { throw failed( Double.valueOf(value), singleViolation(failedPredicate(e))); } return innerCheckD(value, ok, describer); }
/** * <p>Evaluate the given {@code predicate} using {@code value} as input.</p> * * <p>The function throws {@link PostconditionViolationException} 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 PostconditionViolationException If the predicate is false */ public static <T> T checkPostcondition( 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); }
/** * A {@code long} specialized version of {@link #checkPostcondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static long checkPostconditionL( final long value, final ContractLongConditionType condition) throws PostconditionViolationException { return checkPostconditionL( value, condition.predicate(), condition.describer()); }
/** * An {@code int} specialized version of {@link #checkPostcondition(Object, * ContractConditionType)}. * * @param value The value * @param condition The predicate * * @return value * * @throws PostconditionViolationException If the predicate is false */ public static int checkPostconditionI( final int value, final ContractIntConditionType condition) throws PostconditionViolationException { return checkPostconditionI( value, condition.predicate(), condition.describer()); }