com.alibaba.citrus.util.Assert.getMessage()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(139)

本文整理了Java中com.alibaba.citrus.util.Assert.getMessage()方法的一些代码示例,展示了Assert.getMessage()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.getMessage()方法的具体详情如下:
包路径:com.alibaba.citrus.util.Assert
类名称:Assert
方法名:getMessage

Assert.getMessage介绍

[英]取得带参数的消息。
[中]取得带参数的消息。

代码示例

代码示例来源:origin: webx/citrus

/** 确保对象不为空,否则抛出指定异常,默认为<code>IllegalArgumentException</code>。 */
public static <T> T assertNotNull(T object, ExceptionType exceptionType, String message, Object... args) {
  if (object == null) {
    if (exceptionType == null) {
      exceptionType = ILLEGAL_ARGUMENT;
    }
    throw exceptionType.newInstance(getMessage(message, args,
                          "[Assertion failed] - the argument is required; it must not be null"));
  }
  return object;
}

代码示例来源:origin: webx/citrus

/** 确保表达式为真,否则抛出指定异常,默认为<code>IllegalArgumentException</code>。 */
public static void assertTrue(boolean expression, ExceptionType exceptionType, String message, Object... args) {
  if (!expression) {
    if (exceptionType == null) {
      exceptionType = ILLEGAL_ARGUMENT;
    }
    throw exceptionType.newInstance(getMessage(message, args,
                          "[Assertion failed] - the expression must be true"));
  }
}

代码示例来源:origin: webx/citrus

/** 确保表达式为真,否则抛出指定异常,默认为<code>IllegalArgumentException</code>。 */
public static void assertTrue(boolean expression, ExceptionType exceptionType, String message, Object... args) {
  if (!expression) {
    if (exceptionType == null) {
      exceptionType = ILLEGAL_ARGUMENT;
    }
    throw exceptionType.newInstance(getMessage(message, args,
                          "[Assertion failed] - the expression must be true"));
  }
}

代码示例来源:origin: webx/citrus

/** 确保对象为空,否则抛出指定异常,默认为<code>IllegalArgumentException</code>。 */
public static <T> T assertNull(T object, ExceptionType exceptionType, String message, Object... args) {
  if (object != null) {
    if (exceptionType == null) {
      exceptionType = ILLEGAL_ARGUMENT;
    }
    throw exceptionType.newInstance(getMessage(message, args,
                          "[Assertion failed] - the object argument must be null"));
  }
  return object;
}

代码示例来源:origin: webx/citrus

/** 确保对象为空,否则抛出指定异常,默认为<code>IllegalArgumentException</code>。 */
public static <T> T assertNull(T object, ExceptionType exceptionType, String message, Object... args) {
  if (object != null) {
    if (exceptionType == null) {
      exceptionType = ILLEGAL_ARGUMENT;
    }
    throw exceptionType.newInstance(getMessage(message, args,
                          "[Assertion failed] - the object argument must be null"));
  }
  return object;
}

代码示例来源:origin: webx/citrus

/** 确保对象为空,否则抛出指定异常,默认为<code>IllegalArgumentException</code>。 */
public static <T> T assertNull(T object, ExceptionType exceptionType, String message, Object... args) {
  if (object != null) {
    if (exceptionType == null) {
      exceptionType = ILLEGAL_ARGUMENT;
    }
    throw exceptionType.newInstance(getMessage(message, args,
                          "[Assertion failed] - the object argument must be null"));
  }
  return object;
}

代码示例来源:origin: webx/citrus

/** 不可能到达的代码。 */
public static <T> T unreachableCode(String message, Object... args) {
  throw UNREACHABLE_CODE.newInstance(getMessage(message, args,
                         "[Assertion failed] - the code is expected as unreachable"));
}

代码示例来源:origin: webx/citrus

/** 不支持的操作。 */
public static <T> T unsupportedOperation(String message, Object... args) {
  throw UNSUPPORTED_OPERATION.newInstance(getMessage(message, args,
                            "[Assertion failed] - unsupported operation or unimplemented function"));
}

代码示例来源:origin: webx/citrus

/** 不可能到达的代码。 */
public static <T> T unreachableCode(String message, Object... args) {
  throw UNREACHABLE_CODE.newInstance(getMessage(message, args,
                         "[Assertion failed] - the code is expected as unreachable"));
}

代码示例来源:origin: webx/citrus

/** 不支持的操作。 */
public static <T> T unsupportedOperation(String message, Object... args) {
  throw UNSUPPORTED_OPERATION.newInstance(getMessage(message, args,
                            "[Assertion failed] - unsupported operation or unimplemented function"));
}

代码示例来源:origin: webx/citrus

/** 不可能到达的代码。 */
public static <T> T unreachableCode(String message, Object... args) {
  throw UNREACHABLE_CODE.newInstance(getMessage(message, args,
                         "[Assertion failed] - the code is expected as unreachable"));
}

代码示例来源:origin: webx/citrus

/** 确保对象不为空,否则抛出指定异常,默认为<code>IllegalArgumentException</code>。 */
public static <T> T assertNotNull(T object, ExceptionType exceptionType, String message, Object... args) {
  if (object == null) {
    if (exceptionType == null) {
      exceptionType = ILLEGAL_ARGUMENT;
    }
    throw exceptionType.newInstance(getMessage(message, args,
                          "[Assertion failed] - the argument is required; it must not be null"));
  }
  return object;
}

代码示例来源:origin: webx/citrus

/** 确保表达式为真,否则抛出指定异常,默认为<code>IllegalArgumentException</code>。 */
public static void assertTrue(boolean expression, ExceptionType exceptionType, String message, Object... args) {
  if (!expression) {
    if (exceptionType == null) {
      exceptionType = ILLEGAL_ARGUMENT;
    }
    throw exceptionType.newInstance(getMessage(message, args,
                          "[Assertion failed] - the expression must be true"));
  }
}

代码示例来源:origin: webx/citrus

/** 确保对象不为空,否则抛出指定异常,默认为<code>IllegalArgumentException</code>。 */
public static <T> T assertNotNull(T object, ExceptionType exceptionType, String message, Object... args) {
  if (object == null) {
    if (exceptionType == null) {
      exceptionType = ILLEGAL_ARGUMENT;
    }
    throw exceptionType.newInstance(getMessage(message, args,
                          "[Assertion failed] - the argument is required; it must not be null"));
  }
  return object;
}

代码示例来源:origin: webx/citrus

/** 不支持的操作。 */
public static <T> T unsupportedOperation(String message, Object... args) {
  throw UNSUPPORTED_OPERATION.newInstance(getMessage(message, args,
                            "[Assertion failed] - unsupported operation or unimplemented function"));
}

代码示例来源:origin: webx/citrus

/** 未预料的失败。 */
public static <T> T fail(String message, Object... args) {
  throw UNEXPECTED_FAILURE.newInstance(getMessage(message, args, "[Assertion failed] - unexpected failure"));
}

代码示例来源:origin: webx/citrus

/** 未预料的失败。 */
public static <T> T fail(String message, Object... args) {
  throw UNEXPECTED_FAILURE.newInstance(getMessage(message, args, "[Assertion failed] - unexpected failure"));
}

代码示例来源:origin: webx/citrus

/** 不可能发生的异常。 */
public static <T> T unexpectedException(Throwable e, String message, Object... args) {
  RuntimeException exception = UNEXPECTED_FAILURE.newInstance(getMessage(message, args,
                                      "[Assertion failed] - unexpected exception is thrown"));
  exception.initCause(e);
  throw exception;
}

代码示例来源:origin: webx/citrus

/** 不可能发生的异常。 */
public static <T> T unexpectedException(Throwable e, String message, Object... args) {
  RuntimeException exception = UNEXPECTED_FAILURE.newInstance(getMessage(message, args,
                                      "[Assertion failed] - unexpected exception is thrown"));
  exception.initCause(e);
  throw exception;
}

代码示例来源:origin: webx/citrus

/** 不可能发生的异常。 */
public static <T> T unexpectedException(Throwable e, String message, Object... args) {
  RuntimeException exception = UNEXPECTED_FAILURE.newInstance(getMessage(message, args,
                                      "[Assertion failed] - unexpected exception is thrown"));
  exception.initCause(e);
  throw exception;
}

相关文章