/** * A specialized version of {@link #checkInvariant(Object, boolean, Function)} * that does not mention an input value. * * @param condition The predicate * @param message The predicate description * * @throws InvariantViolationException Iff {@code predicate == false} */ public static void checkInvariant( final boolean condition, final String message) throws InvariantViolationException { if (!condition) { throw failed("<unspecified>", singleViolation(message)); } }
/** * A specialized version of {@link #checkInvariant(Object, boolean, Function)} * that does not mention an input value. * * @param condition The predicate * @param message The predicate description * * @throws InvariantViolationException Iff {@code predicate == false} */ public static void checkInvariant( final boolean condition, final String message) throws InvariantViolationException { if (!condition) { throw failed("<unspecified>", singleViolation(message)); } }
/** * A {@code double} specialized version of {@link #checkInvariants(Object, * ContractConditionType[])} * * @param value The value * @param conditions The conditions the value must obey * * @return value * * @throws InvariantViolationException If any of the conditions are false */ public static double checkInvariantsD( final double value, final ContractDoubleConditionType... conditions) throws InvariantViolationException { final Violations violations = innerCheckAllDouble(value, conditions); if (violations != null) { throw failed(Double.valueOf(value), violations); } return value; }
private static long innerCheckInvariantL( 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 innerCheckInvariantD( 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 double innerCheckInvariantD( final double value, final boolean condition, final DoubleFunction<String> describer) { if (!condition) { throw failed( Double.valueOf(value), singleViolation(applyDescriberDChecked(value, describer))); } return value; }
/** * A {@code long} specialized version of {@link #checkInvariants(Object, * ContractConditionType[])} * * @param value The value * @param conditions The conditions the value must obey * * @return value * * @throws InvariantViolationException If any of the conditions are false */ public static long checkInvariantsL( final long value, final ContractLongConditionType... conditions) throws InvariantViolationException { final Violations violations = innerCheckAllLong(value, conditions); if (violations != null) { throw failed(Long.valueOf(value), violations); } return value; }
/** * An {@code int} specialized version of {@link #checkInvariants(Object, * ContractConditionType[])} * * @param value The value * @param conditions The conditions the value must obey * * @return value * * @throws InvariantViolationException If any of the conditions are false */ public static int checkInvariantsI( final int value, final ContractIntConditionType... conditions) throws InvariantViolationException { final Violations violations = innerCheckAllInt(value, conditions); if (violations != null) { throw failed(Integer.valueOf(value), violations); } return value; }
/** * A {@code long} specialized version of {@link #checkInvariants(Object, * ContractConditionType[])} * * @param value The value * @param conditions The conditions the value must obey * * @return value * * @throws InvariantViolationException If any of the conditions are false */ public static long checkInvariantsL( final long value, final ContractLongConditionType... conditions) throws InvariantViolationException { final Violations violations = innerCheckAllLong(value, conditions); if (violations != null) { throw failed(Long.valueOf(value), violations); } return value; }
/** * An {@code int} specialized version of {@link #checkInvariants(Object, * ContractConditionType[])} * * @param value The value * @param conditions The conditions the value must obey * * @return value * * @throws InvariantViolationException If any of the conditions are false */ public static int checkInvariantsI( final int value, final ContractIntConditionType... conditions) throws InvariantViolationException { final Violations violations = innerCheckAllInt(value, conditions); if (violations != null) { throw failed(Integer.valueOf(value), violations); } return value; }
private static int innerCheckInvariantI( final int value, final boolean condition, final IntFunction<String> describer) { if (!condition) { throw failed( Integer.valueOf(value), singleViolation(applyDescriberIChecked(value, describer))); } return value; }
/** * <p>A version of {@link #checkInvariant(boolean, String)} that constructs a * description message from the given format string and arguments.</p> * * <p>Note that the use of variadic arguments may entail allocating memory on * virtual machines that fail to eliminate the allocations with <i>escape * analysis</i>.</p> * * @param value The value * @param condition The predicate * @param format The format string * @param objects The format string arguments * @param <T> The precise type of values * * @return {@code value} * * @since 1.1.0 */ public static <T> T checkInvariantV( final T value, final boolean condition, final String format, final Object... objects) { if (!condition) { throw failed(value, singleViolation(String.format(format, objects))); } return value; }
private static long innerCheckInvariantL( 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 innerCheckInvariantI( 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 <T> T innerCheckInvariant( 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 innerCheckInvariant( 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 #checkInvariant(Object, boolean, Function)} * that does not mention an input value. * * @param condition The predicate * @param message The predicate description supplier * * @throws InvariantViolationException Iff {@code predicate == false} */ public static void checkInvariant( final boolean condition, final Supplier<String> message) throws InvariantViolationException { if (!condition) { throw failed( "<unspecified>", singleViolation(applySupplierChecked(message))); } }
/** * A specialized version of {@link #checkInvariant(Object, boolean, Function)} * that does not mention an input value. * * @param condition The predicate * @param message The predicate description supplier * * @throws InvariantViolationException Iff {@code predicate == false} */ public static void checkInvariant( final boolean condition, final Supplier<String> message) throws InvariantViolationException { if (!condition) { throw failed( "<unspecified>", singleViolation(applySupplierChecked(message))); } }
/** * A {@code long} specialized version of {@link #checkInvariant(Object, * Predicate, Function)} * * @param value The value * @param predicate The predicate * @param describer The describer of the predicate * * @return value * * @throws InvariantViolationException If the predicate is false */ public static long checkInvariantL( 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 innerCheckInvariantL(value, ok, describer); }
/** * A {@code long} specialized version of {@link #checkInvariant(Object, * Predicate, Function)} * * @param value The value * @param predicate The predicate * @param describer The describer of the predicate * * @return value * * @throws InvariantViolationException If the predicate is false */ public static long checkInvariantL( 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 innerCheckInvariantL(value, ok, describer); }