/*
* Copyright 2002-2012 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
* use this file except in compliance with the License. You may obtain a copy of
* the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
* License for the specific language governing permissions and limitations under
* the License.
*/
package edu.gdut.util;
import java.util.Collection;
import java.util.Iterator;
import java.util.Map;
import org.nutz.lang.Lang;
import org.nutz.lang.Strings;
/**
* Assertion utility class that assists in validating arguments.
* Useful for identifying programmer errors early and clearly at runtime.
* <p>
* <p>For example, if the contract of a public method states it does not
* allow {@code null} arguments, Assert can be used to validate that
* contract. Doing this clearly indicates a contract violation when it
* occurs and protects the class's invariants.
* <p>
* <p>Typically used to validate method arguments rather than configuration
* properties, to check for cases that are usually programmer errors rather than
* configuration errors. In contrast to config initialization code, there is
* usally no point in falling back to defaults in such methods.
* <p>
* <p>This class is similar to JUnit's assertion library. If an argument value is
* deemed invalid, an {@link IllegalArgumentException} is thrown (typically).
* For example:
* <p>
* <pre class="code">
* Assert.notNull(clazz, "The class must not be null");
* Assert.isTrue(i > 0, "The value must be greater than zero");</pre>
* <p>
* Mainly for internal use within the framework; consider Jakarta's Commons Lang
* >= 2.0 for a more comprehensive suite of assertion utilities.
*
* @author Keith Donald
* @author Juergen Hoeller
* @author Colin Sampaleanu
* @author Rob Harrop
* @since 1.1.2
*/
public abstract class Assert {
/**
* Assert a boolean expression, throwing {@code IllegalArgumentException}
* if the test result is {@code false}.
* <pre class="code">Assert.isTrue(i > 0, "The value must be greater than zero");</pre>
*
* @param expression a boolean expression
* @param message the exception message to use if the assertion fails
* @throws IllegalArgumentException if expression is {@code false}
*/
public static void isTrue(boolean expression, String message) {
if (!expression) {
throw new IllegalArgumentException(message);
}
}
/**
* Assert a boolean expression, throwing {@code IllegalArgumentException}
* if the test result is {@code false}.
* <pre class="code">Assert.isTrue(i > 0);</pre>
*
* @param expression a boolean expression
* @throws IllegalArgumentException if expression is {@code false}
*/
public static void isTrue(boolean expression) {
isTrue(expression, "[Assertion failed] - this expression must be true");
}
/**
* Assert that an object is {@code null} .
* <pre class="code">Assert.isNull(value, "The value must be null");</pre>
*
* @param object the object to check
* @param message the exception message to use if the assertion fails
* @throws IllegalArgumentException if the object is not {@code null}
*/
public static void isNull(Object object, String message) {
if (object != null) {
throw new IllegalArgumentException(message);
}
}
/**
* Assert that an object is {@code null} .
* <pre class="code">Assert.isNull(value);</pre>
*
* @param object the object to check
* @throws IllegalArgumentException if the object is not {@code null}
*/
public static void isNull(Object object) {
isNull(object, "[Assertion failed] - the object argument must be null");
}
/**
* Assert that an object is not {@code null} .
* <pre class="code">Assert.notNull(clazz, "The class must not be null");</pre>
*
* @param object the object to check
* @param message the exception message to use if the assertion fails
* @throws IllegalArgumentException if the object is {@code null}
*/
public static void notNull(Object object, String message) {
if (object == null) {
throw new IllegalArgumentException(message);
}
}
/**
* Assert that an object is not {@code null} .
* <pre class="code">Assert.notNull(clazz);</pre>
*
* @param object the object to check
* @throws IllegalArgumentException if the object is {@code null}
*/
public static void notNull(Object object) {
notNull(object, "[Assertion failed] - this argument is required; it must not be null");
}
/**
* Assert that the given String is not empty; that is,
* it must not be {@code null} and not the empty String.
* <pre class="code">Assert.hasLength(name, "Name must not be empty");</pre>
*
* @param text the String to check
* @param message the exception message to use if the assertion fails
*
*/
public static void hasLength(String text, String message) {
if (Strings.isEmpty(text)) {
throw new IllegalArgumentException(message);
}
}
/**
* Assert that the given String is not empty; that is,
* it must not be {@code null} and not the empty String.
* <pre class="code">Assert.hasLength(name);</pre>
*
* @param text the String to check
*
*/
public static void hasLength(String text) {
hasLength(text,
"[Assertion failed] - this String argument must have length; it must not be null or empty");
}
/**
* Assert that the given String has valid text content; that is, it must not
* be {@code null} and must contain at least one non-whitespace character.
* <pre class="code">Assert.hasText(name, "'name' must not be empty");</pre>
*
* @param text the String to check
* @param message the exception message to use if the assertion fails
*
*/
public static void hasText(String text, String message) {
if (Strings.isEmpty(text)) {
throw new IllegalArgumentException(message);
}
}
/**
* Assert that the given String has valid text content; that is, it must not
* be {@code null} and must contain at least one non-whitespace character.
* <pre class="code">Assert.hasText(name, "'name' must not be empty");</pre>
*
* @param text the String to check
*
*/
public static void hasText(String text) {
hasText(text,
"[Assertion failed] - this String argument must have text; it must not be null, empty, or blank");
}
/**
* Assert that the given text does not contain the given substring.
* <pre class="code">Assert.doesNotContain(name, "rod", "Name must not contain 'rod'");</pre>
*
* @param textToSearch the text to search
* @param substring the substring to find within the text
* @param message the exception message to use if the assertion fails
*/
public static void doesNotContain(String textToSearch, String substring, String message) {
if (!Strings.isEmpty(textToSearch) && !Strings.isEmpty(substring) &&
textToSearch.indexOf(substring) != -1) {
throw new IllegalArgumentException(message);
}
}
/**
* Assert that the given text does not contain the given substring.
* <pre class="code">Assert.doesNotContain(name, "rod");</pre>
*
* @param textToSearch the text to search
* @param substring the substring to find within the text
*/
public static void doesNotContain(Str
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
分类算法DS证据推理遗传算法_Reliability.zip (69个子文件)
Reliability-master
src
test
java
edu
gdut
test
XlsTest.java 2KB
DSTest.java 377B
IRETest.java 1KB
MatrixTest.java 727B
GATest.java 2KB
AUCTest.java 1KB
main
resources
log4j.properties 260B
static
index.html 449B
static
js
app.ce84e80e66331f10ceab.js.map 84KB
manifest.a45df110ae3f784153b1.js.map 9KB
app.ce84e80e66331f10ceab.js 14KB
vendor.fe84bc6407938a2f4414.js.map 993KB
manifest.a45df110ae3f784153b1.js 832B
vendor.fe84bc6407938a2f4414.js 144KB
img
logo_simple.958b001.png 91KB
css
app.500202848fd98520a2c0a01c36616340.css 101KB
app.500202848fd98520a2c0a01c36616340.css.map 165KB
config
application.properties 1KB
java
edu
gdut
Application.java 457B
controller
TaskListController.java 659B
UploadController.java 1KB
CalculationController.java 1KB
DownloadController.java 2KB
dao
CalTaskMapper.java 934B
service
Cal.java 354B
CalService.java 4KB
GA
FitnessCal.java 302B
DistanceFitnessCal.java 2KB
Individual.java 2KB
AucFitnessCal.java 2KB
Population.java 2KB
GA.java 3KB
AucFitnessCal2.java 2KB
PopComparator.java 818B
TaskListService.java 757B
DS
SimDistance.java 371B
Measure.java 185B
JousselmeDistance.java 3KB
ElementHead.java 2KB
Crd1.java 802B
Evidence.java 4KB
DistanceMeasure.java 397B
CompositeUtil.java 2KB
EvidenceDS.java 6KB
Evidences.java 3KB
EvidenceUtil.java 954B
SupFunction.java 665B
Crd2.java 1KB
Element.java 4KB
reliability
Common.java 4KB
IRE.java 2KB
CRE4ThreeEle.java 3KB
ICRE.java 4KB
IIRE.java 2KB
IRE4ThreeEle.java 9KB
CRE.java 5KB
AUC.java 4KB
util
XlsUtil.java 5KB
ArraysUtil.java 3KB
Arrange.java 2KB
Combination.java 1KB
FileUtil.java 658B
Assert.java 17KB
StringUtil.java 474B
domain
AUCBean.java 750B
CalTask.java 3KB
build.gradle 2KB
settings.gradle 34B
.gitignore 189B
共 69 条
- 1
资源评论
好家伙VCC
- 粉丝: 2441
- 资源: 9138
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- 制冷剂管道设计和制造指南.pdf
- BRYANT制冷设备应用指南和维修手册.pdf
- 制冷管路设计指南Refrigerant Piping Design Guide Daikin AG 31-011 LR.pdf
- 环境标志产品技术要求 工商用制冷设备.pdf
- 工业制冷氨和二氧化碳应用.pdf
- 集成式制冷机房应用技术规程.pdf
- 冰箱压缩机参考设计用户指南.pdf
- APP-PRC006A-EN_02252021.pdf
- Polarcraft Brochure_July 2021_V2-1.pdf
- 蒸发式冷凝器工程手册.pdf
- 基于ZH5120设计的硬件技术开发资料.zip
- 模拟量滤波程序 西门子200smart程序,能实现电流电压和热电阻模拟量信号的采集,有滤波,有高位和低位报警,采用for循环指令和间接寻址,让程序简单好用,并且针对程序,录制了视频讲解,详细的介绍了程
- 基于ZH5212设计的产品电路原理图+PCB.zip
- 基于ZH5210设计的产品电路原理图+PCB.zip
- 基于ZH5213设计的产品电路原理图+PCB.zip
- 永磁同步电机矢量控制仿真,带SVPWM发波模块
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功