/** * A {@code long} specialized version of {@link #checkPostconditions(Object, * ContractConditionType[])} * * @param value The value * @param conditions The conditions the value must obey * * @return value * * @throws PostconditionViolationException If any of the conditions are false */ public static long checkPostconditionsL( final long value, final ContractLongConditionType... conditions) throws PostconditionViolationException { final Violations violations = innerCheckAllLong(value, conditions); if (violations != null) { throw failed(Long.valueOf(value), violations); } return value; }
/** * A {@code double} specialized version of {@link #checkPostconditions(Object, * ContractConditionType[])} * * @param value The value * @param conditions The conditions the value must obey * * @return value * * @throws PostconditionViolationException If any of the conditions are false */ public static double checkPostconditionsD( final double value, final ContractDoubleConditionType... conditions) throws PostconditionViolationException { final Violations violations = innerCheckAllDouble(value, conditions); if (violations != null) { throw failed(Double.valueOf(value), violations); } return value; }
/** * 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)); } }
/** * 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)); } }
/** * A {@code long} specialized version of {@link #checkPostconditions(Object, * ContractConditionType[])} * * @param value The value * @param conditions The conditions the value must obey * * @return value * * @throws PostconditionViolationException If any of the conditions are false */ public static long checkPostconditionsL( final long value, final ContractLongConditionType... conditions) throws PostconditionViolationException { final Violations violations = innerCheckAllLong(value, conditions); if (violations != null) { throw failed(Long.valueOf(value), violations); } return value; }
/** * A {@code double} specialized version of {@link #checkPostconditions(Object, * ContractConditionType[])} * * @param value The value * @param conditions The conditions the value must obey * * @return value * * @throws PostconditionViolationException If any of the conditions are false */ public static double checkPostconditionsD( final double value, final ContractDoubleConditionType... conditions) throws PostconditionViolationException { final Violations violations = innerCheckAllDouble(value, conditions); if (violations != null) { throw failed(Double.valueOf(value), violations); } return value; }
/** * An {@code int} specialized version of {@link #checkPostconditions(Object, * ContractConditionType[])} * * @param value The value * @param conditions The conditions the value must obey * * @return value * * @throws PostconditionViolationException If any of the conditions are false */ public static int checkPostconditionsI( final int value, final ContractIntConditionType... conditions) throws PostconditionViolationException { final Violations violations = innerCheckAllInt(value, conditions); if (violations != null) { throw failed(Integer.valueOf(value), violations); } return value; }
/** * An {@code int} specialized version of {@link #checkPostconditions(Object, * ContractConditionType[])} * * @param value The value * @param conditions The conditions the value must obey * * @return value * * @throws PostconditionViolationException If any of the conditions are false */ public static int checkPostconditionsI( final int value, final ContractIntConditionType... conditions) throws PostconditionViolationException { final Violations violations = innerCheckAllInt(value, conditions); if (violations != null) { throw failed(Integer.valueOf(value), violations); } return value; }
private static int innerCheckI( final int value, final boolean condition, final IntFunction<String> describer) { if (!condition) { throw failed( Integer.valueOf(value), singleViolation(applyDescriberIChecked(value, describer))); } return value; }
private static long innerCheckL( final long value, final boolean condition, final LongFunction<String> describer) { if (!condition) { throw failed( Long.valueOf(value), singleViolation(applyDescriberLChecked(value, describer))); } return value; }
private static int innerCheckI( final int value, final boolean condition, final IntFunction<String> describer) { if (!condition) { throw failed( Integer.valueOf(value), singleViolation(applyDescriberIChecked(value, describer))); } return value; }
private static double innerCheckD( final double value, final boolean condition, final DoubleFunction<String> describer) { if (!condition) { throw failed( Double.valueOf(value), singleViolation(applyDescriberDChecked(value, describer))); } return value; }
private static long innerCheckL( final long value, final boolean condition, final LongFunction<String> describer) { if (!condition) { throw failed( Long.valueOf(value), singleViolation(applyDescriberLChecked(value, describer))); } return value; }
private static double innerCheckD( final double value, final boolean condition, final DoubleFunction<String> describer) { if (!condition) { throw failed( Double.valueOf(value), singleViolation(applyDescriberDChecked(value, describer))); } return value; }
private static <T> T innerCheck( final T value, final boolean condition, final Function<T, String> describer) { if (!condition) { throw failed( value, singleViolation(applyDescriberChecked(value, describer))); } return value; }
private static <T> T innerCheck( final T value, final boolean condition, final Function<T, String> describer) { if (!condition) { throw failed( value, singleViolation(applyDescriberChecked(value, describer))); } return value; }
/** * 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 supplier * * @throws PostconditionViolationException Iff {@code predicate == false} */ public static void checkPostcondition( final boolean condition, final Supplier<String> message) throws PostconditionViolationException { if (!condition) { throw failed( "<unspecified>", singleViolation(applySupplierChecked(message))); } }
/** * 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 supplier * * @throws PostconditionViolationException Iff {@code predicate == false} */ public static void checkPostcondition( final boolean condition, final Supplier<String> message) throws PostconditionViolationException { if (!condition) { throw failed( "<unspecified>", singleViolation(applySupplierChecked(message))); } }
/** * 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); }