本文整理了Java中com.io7m.jaffirm.core.Preconditions.failed()
方法的一些代码示例,展示了Preconditions.failed()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Preconditions.failed()
方法的具体详情如下:
包路径:com.io7m.jaffirm.core.Preconditions
类名称:Preconditions
方法名:failed
暂无
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
/**
* A specialized version of {@link #checkPrecondition(Object, boolean,
* Function)} that does not mention an input value.
*
* @param condition The predicate
* @param message The predicate description
*
* @throws PreconditionViolationException Iff {@code predicate == false}
*/
public static void checkPrecondition(
final boolean condition,
final String message)
throws PreconditionViolationException
{
if (!condition) {
throw failed("<unspecified>", singleViolation(message));
}
}
代码示例来源:origin: com.io7m.jaffirm/io7m-jaffirm-core
/**
* A specialized version of {@link #checkPrecondition(Object, boolean,
* Function)} that does not mention an input value.
*
* @param condition The predicate
* @param message The predicate description
*
* @throws PreconditionViolationException Iff {@code predicate == false}
*/
public static void checkPrecondition(
final boolean condition,
final String message)
throws PreconditionViolationException
{
if (!condition) {
throw failed("<unspecified>", singleViolation(message));
}
}
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
/**
* A {@code double} specialized version of {@link #checkPreconditions(Object,
* ContractConditionType[])}
*
* @param value The value
* @param conditions The conditions the value must obey
*
* @return value
*
* @throws PreconditionViolationException If any of the conditions are false
*/
public static double checkPreconditionsD(
final double value,
final ContractDoubleConditionType... conditions)
throws PreconditionViolationException
{
final Violations violations = innerCheckAllDouble(value, conditions);
if (violations != null) {
throw failed(Double.valueOf(value), violations);
}
return value;
}
代码示例来源:origin: com.io7m.jaffirm/io7m-jaffirm-core
/**
* A {@code long} specialized version of {@link #checkPreconditions(Object,
* ContractConditionType[])}
*
* @param value The value
* @param conditions The conditions the value must obey
*
* @return value
*
* @throws PreconditionViolationException If any of the conditions are false
*/
public static long checkPreconditionsL(
final long value,
final ContractLongConditionType... conditions)
throws PreconditionViolationException
{
final Violations violations = innerCheckAllLong(value, conditions);
if (violations != null) {
throw failed(Long.valueOf(value), violations);
}
return value;
}
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
/**
* An {@code int} specialized version of {@link #checkPreconditions(Object,
* ContractConditionType[])}
*
* @param value The value
* @param conditions The conditions the value must obey
*
* @return value
*
* @throws PreconditionViolationException If any of the conditions are false
*/
public static int checkPreconditionsI(
final int value,
final ContractIntConditionType... conditions)
throws PreconditionViolationException
{
final Violations violations = innerCheckAllInt(value, conditions);
if (violations != null) {
throw failed(Integer.valueOf(value), violations);
}
return value;
}
代码示例来源:origin: com.io7m.jaffirm/io7m-jaffirm-core
/**
* An {@code int} specialized version of {@link #checkPreconditions(Object,
* ContractConditionType[])}
*
* @param value The value
* @param conditions The conditions the value must obey
*
* @return value
*
* @throws PreconditionViolationException If any of the conditions are false
*/
public static int checkPreconditionsI(
final int value,
final ContractIntConditionType... conditions)
throws PreconditionViolationException
{
final Violations violations = innerCheckAllInt(value, conditions);
if (violations != null) {
throw failed(Integer.valueOf(value), violations);
}
return value;
}
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
/**
* A {@code long} specialized version of {@link #checkPreconditions(Object,
* ContractConditionType[])}
*
* @param value The value
* @param conditions The conditions the value must obey
*
* @return value
*
* @throws PreconditionViolationException If any of the conditions are false
*/
public static long checkPreconditionsL(
final long value,
final ContractLongConditionType... conditions)
throws PreconditionViolationException
{
final Violations violations = innerCheckAllLong(value, conditions);
if (violations != null) {
throw failed(Long.valueOf(value), violations);
}
return value;
}
代码示例来源:origin: com.io7m.jaffirm/io7m-jaffirm-core
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;
}
代码示例来源:origin: com.io7m.jaffirm/io7m-jaffirm-core
/**
* A {@code double} specialized version of {@link #checkPreconditions(Object,
* ContractConditionType[])}
*
* @param value The value
* @param conditions The conditions the value must obey
*
* @return value
*
* @throws PreconditionViolationException If any of the conditions are false
*/
public static double checkPreconditionsD(
final double value,
final ContractDoubleConditionType... conditions)
throws PreconditionViolationException
{
final Violations violations = innerCheckAllDouble(value, conditions);
if (violations != null) {
throw failed(Double.valueOf(value), violations);
}
return value;
}
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
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;
}
代码示例来源:origin: com.io7m.jaffirm/io7m-jaffirm-core
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;
}
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
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;
}
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
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;
}
代码示例来源:origin: com.io7m.jaffirm/io7m-jaffirm-core
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;
}
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
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;
}
代码示例来源:origin: com.io7m.jaffirm/io7m-jaffirm-core
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;
}
代码示例来源:origin: com.io7m.jaffirm/io7m-jaffirm-core
/**
* A specialized version of {@link #checkPrecondition(Object, boolean,
* Function)} that does not mention an input value.
*
* @param condition The predicate
* @param message The predicate description supplier
*
* @throws PreconditionViolationException Iff {@code predicate == false}
*/
public static void checkPrecondition(
final boolean condition,
final Supplier<String> message)
throws PreconditionViolationException
{
if (!condition) {
throw failed(
"<unspecified>", singleViolation(applySupplierChecked(message)));
}
}
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
/**
* A specialized version of {@link #checkPrecondition(Object, boolean,
* Function)} that does not mention an input value.
*
* @param condition The predicate
* @param message The predicate description supplier
*
* @throws PreconditionViolationException Iff {@code predicate == false}
*/
public static void checkPrecondition(
final boolean condition,
final Supplier<String> message)
throws PreconditionViolationException
{
if (!condition) {
throw failed(
"<unspecified>", singleViolation(applySupplierChecked(message)));
}
}
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
/**
* <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);
}
代码示例来源:origin: com.io7m.jaffirm/com.io7m.jaffirm.core
/**
* A {@code double} specialized version of {@link #checkPrecondition(Object,
* Predicate, Function)}
*
* @param value The value
* @param predicate The predicate
* @param describer The describer of the predicate
*
* @return value
*
* @throws PreconditionViolationException If the predicate is false
*/
public static double checkPreconditionD(
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);
}
内容来源于网络,如有侵权,请联系作者删除!