本文整理了Java中cn.hutool.core.lang.Assert.isFalse()
方法的一些代码示例,展示了Assert.isFalse()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assert.isFalse()
方法的具体详情如下:
包路径:cn.hutool.core.lang.Assert
类名称:Assert
方法名:isFalse
[英]断言是否为假,如果为 true 抛出 IllegalArgumentException 异常
Assert.isFalse(i < 0);
[中]断言是否为假,如果为 符合事实的抛出 非法辩论例外异常
Assert.isFalse(i < 0);
代码示例来源:origin: looly/hutool
/**
* 检查是否未关闭状态
*/
private void checkNotClosed() {
Assert.isFalse(this.isClosed, "ExcelReader has been closed!");
}
// ------------------------------------------------------------------------------------------------------- Private methods end
代码示例来源:origin: looly/hutool
/**
* 断言是否为假,如果为 {@code true} 抛出 {@code IllegalArgumentException} 异常<br>
*
* <pre class="code">
* Assert.isFalse(i < 0);
* </pre>
*
* @param expression 波尔值
* @throws IllegalArgumentException if expression is {@code false}
*/
public static void isFalse(boolean expression) throws IllegalArgumentException {
isFalse(expression, "[Assertion failed] - this expression must be false");
}
代码示例来源:origin: looly/hutool
/**
* 检查是否未关闭状态
*/
private void checkNotClosed() {
Assert.isFalse(this.isClosed, "ExcelReader has been closed!");
}
// ------------------------------------------------------------------------------------------------------- Private methods end
代码示例来源:origin: looly/hutool
/**
* 断言是否为假,如果为 {@code true} 抛出 {@code IllegalArgumentException} 异常<br>
*
* <pre class="code">
* Assert.isFalse(i < 0);
* </pre>
*
* @param expression 波尔值
* @throws IllegalArgumentException if expression is {@code false}
*/
public static void isFalse(boolean expression) throws IllegalArgumentException {
isFalse(expression, "[Assertion failed] - this expression must be false");
}
代码示例来源:origin: looly/hutool
/**
* 合并某行的单元格,并写入对象到单元格<br>
* 如果写到单元格中的内容非null,行号自动+1,否则当前行号不变<br>
* 样式为默认标题样式,可使用{@link #getHeadCellStyle()}方法调用后自定义默认样式
*
* @param lastColumn 合并到的最后一个列号
* @param content 合并单元格后的内容
* @param isSetHeaderStyle 是否为合并后的单元格设置默认标题样式
* @return this
* @since 4.0.10
*/
public ExcelWriter merge(int lastColumn, Object content, boolean isSetHeaderStyle) {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
final int rowIndex = this.currentRow.get();
merge(rowIndex, rowIndex, 0, lastColumn, content, isSetHeaderStyle);
// 设置内容后跳到下一行
if (null != content) {
this.currentRow.incrementAndGet();
}
return this;
}
代码示例来源:origin: looly/hutool
/**
* 合并某行的单元格,并写入对象到单元格<br>
* 如果写到单元格中的内容非null,行号自动+1,否则当前行号不变<br>
* 样式为默认标题样式,可使用{@link #getHeadCellStyle()}方法调用后自定义默认样式
*
* @param lastColumn 合并到的最后一个列号
* @param content 合并单元格后的内容
* @param isSetHeaderStyle 是否为合并后的单元格设置默认标题样式
* @return this
* @since 4.0.10
*/
public ExcelWriter merge(int lastColumn, Object content, boolean isSetHeaderStyle) {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
final int rowIndex = this.currentRow.get();
merge(rowIndex, rowIndex, 0, lastColumn, content, isSetHeaderStyle);
// 设置内容后跳到下一行
if (null != content) {
this.currentRow.incrementAndGet();
}
return this;
}
代码示例来源:origin: looly/hutool
/**
* 写出一行标题数据<br>
* 本方法只是将数据写入Workbook中的Sheet,并不写出到文件<br>
* 写出的起始行为当前行号,可使用{@link #getCurrentRow()}方法调用,根据写出的的行数,当前行号自动+1<br>
* 样式为默认标题样式,可使用{@link #getHeadCellStyle()}方法调用后自定义默认样式
*
* @param rowData 一行的数据
* @return this
*/
public ExcelWriter writeHeadRow(Iterable<?> rowData) {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
RowUtil.writeRow(this.sheet.createRow(this.currentRow.getAndIncrement()), rowData, this.styleSet, true);
return this;
}
代码示例来源:origin: looly/hutool
/**
* 写出一行数据<br>
* 本方法只是将数据写入Workbook中的Sheet,并不写出到文件<br>
* 写出的起始行为当前行号,可使用{@link #getCurrentRow()}方法调用,根据写出的的行数,当前行号自动+1<br>
* 样式为默认样式,可使用{@link #getCellStyle()}方法调用后自定义默认样式
*
* @param rowData 一行的数据
* @return this
*/
public ExcelWriter writeRow(Iterable<?> rowData) {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
RowUtil.writeRow(this.sheet.createRow(this.currentRow.getAndIncrement()), rowData, this.styleSet, false);
return this;
}
代码示例来源:origin: looly/hutool
/**
* 写出一行标题数据<br>
* 本方法只是将数据写入Workbook中的Sheet,并不写出到文件<br>
* 写出的起始行为当前行号,可使用{@link #getCurrentRow()}方法调用,根据写出的的行数,当前行号自动+1<br>
* 样式为默认标题样式,可使用{@link #getHeadCellStyle()}方法调用后自定义默认样式
*
* @param rowData 一行的数据
* @return this
*/
public ExcelWriter writeHeadRow(Iterable<?> rowData) {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
RowUtil.writeRow(this.sheet.createRow(this.currentRow.getAndIncrement()), rowData, this.styleSet, true);
return this;
}
代码示例来源:origin: looly/hutool
/**
* 写出一行数据<br>
* 本方法只是将数据写入Workbook中的Sheet,并不写出到文件<br>
* 写出的起始行为当前行号,可使用{@link #getCurrentRow()}方法调用,根据写出的的行数,当前行号自动+1<br>
* 样式为默认样式,可使用{@link #getCellStyle()}方法调用后自定义默认样式
*
* @param rowData 一行的数据
* @return this
*/
public ExcelWriter writeRow(Iterable<?> rowData) {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
RowUtil.writeRow(this.sheet.createRow(this.currentRow.getAndIncrement()), rowData, this.styleSet, false);
return this;
}
代码示例来源:origin: looly/hutool
/**
* 标准化Path格式
*
* @param path Path
* @return 标准化后的path
*/
private String normalizePath(String path) {
// 标准化路径
path = FileUtil.normalize(path);
path = StrUtil.removePrefix(path, StrUtil.SLASH);
Assert.isFalse(FileUtil.isAbsolutePath(path), "Path [{}] must be a relative path !", path);
return path;
}
}
代码示例来源:origin: looly/hutool
/**
* 将Word Document刷出到输出流
*
* @param out 输出流
* @param isCloseOut 是否关闭输出流
* @return this
* @throws IORuntimeException IO异常
*/
public Word07Writer flush(OutputStream out, boolean isCloseOut) throws IORuntimeException {
Assert.isFalse(this.isClosed, "WordWriter has been closed!");
try {
this.doc.write(out);
out.flush();
} catch (IOException e) {
throw new IORuntimeException(e);
} finally {
if (isCloseOut) {
IoUtil.close(out);
}
}
return this;
}
代码示例来源:origin: looly/hutool
/**
* 标准化Path格式
*
* @param path Path
* @return 标准化后的path
*/
private String normalizePath(String path) {
// 标准化路径
path = FileUtil.normalize(path);
path = StrUtil.removePrefix(path, StrUtil.SLASH);
Assert.isFalse(FileUtil.isAbsolutePath(path), "Path [{}] must be a relative path !", path);
return path;
}
}
代码示例来源:origin: looly/hutool
/**
* 将Excel Workbook刷出到输出流
*
* @param out 输出流
* @param isCloseOut 是否关闭输出流
* @return this
* @throws IORuntimeException IO异常
* @since 4.4.1
*/
public ExcelWriter flush(OutputStream out, boolean isCloseOut) throws IORuntimeException {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
try {
this.workbook.write(out);
out.flush();
} catch (IOException e) {
throw new IORuntimeException(e);
} finally {
if(isCloseOut) {
IoUtil.close(out);
}
}
return this;
}
代码示例来源:origin: looly/hutool
/**
* 将一个Map写入到Excel,isWriteKeyAsHead为true写出两行,Map的keys做为一行,values做为第二行,否则只写出一行values<br>
* 如果rowMap为空(包括null),则写出空行
*
* @param rowMap 写出的Map,为空(包括null),则写出空行
* @param isWriteKeyAsHead 为true写出两行,Map的keys做为一行,values做为第二行,否则只写出一行values
* @return this
*/
public ExcelWriter writeRow(Map<?, ?> rowMap, boolean isWriteKeyAsHead) {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
if (MapUtil.isEmpty(rowMap)) {
// 如果写出数据为null或空,跳过当前行
return passCurrentRow();
}
final Map<?, ?> aliasMap = aliasMap(rowMap);
if (isWriteKeyAsHead) {
writeHeadRow(aliasMap.keySet());
}
writeRow(aliasMap.values());
return this;
}
代码示例来源:origin: looly/hutool
/**
* 合并某行的单元格,并写入对象到单元格<br>
* 如果写到单元格中的内容非null,行号自动+1,否则当前行号不变<br>
* 样式为默认标题样式,可使用{@link #getHeadCellStyle()}方法调用后自定义默认样式
*
* @param lastColumn 合并到的最后一个列号
* @param content 合并单元格后的内容
* @param isSetHeaderStyle 是否为合并后的单元格设置默认标题样式
* @return this
* @since 4.0.10
*/
public ExcelWriter merge(int firstRow, int lastRow, int firstColumn, int lastColumn, Object content, boolean isSetHeaderStyle) {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
final CellStyle style = (isSetHeaderStyle && null != this.styleSet && null != this.styleSet.headCellStyle) ? this.styleSet.headCellStyle : this.styleSet.cellStyle;
CellUtil.mergingCells(this.sheet, firstRow, lastRow, firstColumn, lastColumn, style);
// 设置内容
if (null != content) {
final Cell cell = getOrCreateCell(firstColumn, firstRow);
CellUtil.setCellValue(cell, content, this.styleSet, isSetHeaderStyle);
}
return this;
}
代码示例来源:origin: looly/hutool
/**
* 将一个Map写入到Excel,isWriteKeyAsHead为true写出两行,Map的keys做为一行,values做为第二行,否则只写出一行values<br>
* 如果rowMap为空(包括null),则写出空行
*
* @param rowMap 写出的Map,为空(包括null),则写出空行
* @param isWriteKeyAsHead 为true写出两行,Map的keys做为一行,values做为第二行,否则只写出一行values
* @return this
*/
public ExcelWriter writeRow(Map<?, ?> rowMap, boolean isWriteKeyAsHead) {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
if (MapUtil.isEmpty(rowMap)) {
// 如果写出数据为null或空,跳过当前行
return passCurrentRow();
}
final Map<?, ?> aliasMap = aliasMap(rowMap);
if (isWriteKeyAsHead) {
writeHeadRow(aliasMap.keySet());
}
writeRow(aliasMap.values());
return this;
}
代码示例来源:origin: looly/hutool
/**
* 合并某行的单元格,并写入对象到单元格<br>
* 如果写到单元格中的内容非null,行号自动+1,否则当前行号不变<br>
* 样式为默认标题样式,可使用{@link #getHeadCellStyle()}方法调用后自定义默认样式
*
* @param lastColumn 合并到的最后一个列号
* @param content 合并单元格后的内容
* @param isSetHeaderStyle 是否为合并后的单元格设置默认标题样式
* @return this
* @since 4.0.10
*/
public ExcelWriter merge(int firstRow, int lastRow, int firstColumn, int lastColumn, Object content, boolean isSetHeaderStyle) {
Assert.isFalse(this.isClosed, "ExcelWriter has been closed!");
final CellStyle style = (isSetHeaderStyle && null != this.styleSet && null != this.styleSet.headCellStyle) ? this.styleSet.headCellStyle : this.styleSet.cellStyle;
CellUtil.mergingCells(this.sheet, firstRow, lastRow, firstColumn, lastColumn, style);
// 设置内容
if (null != content) {
final Cell cell = getOrCreateCell(firstColumn, firstRow);
CellUtil.setCellValue(cell, content, this.styleSet, isSetHeaderStyle);
}
return this;
}
代码示例来源:origin: looly/hutool
/**
* 图像类型转换:GIF=》JPG、GIF=》PNG、PNG=》JPG、PNG=》GIF(X)、BMP=》PNG
*
* @param srcImageFile 源图像文件
* @param destImageFile 目标图像文件
*/
public static void convert(File srcImageFile, File destImageFile) {
Assert.notNull(srcImageFile);
Assert.notNull(destImageFile);
Assert.isFalse(srcImageFile.equals(destImageFile), "Src file is equals to dest file!");
final String srcExtName = FileUtil.extName(srcImageFile);
final String destExtName = FileUtil.extName(destImageFile);
if (StrUtil.equalsIgnoreCase(srcExtName, destExtName)) {
// 扩展名相同直接复制文件
FileUtil.copy(srcImageFile, destImageFile, true);
}
ImageOutputStream imageOutputStream = null;
try {
imageOutputStream = getImageOutputStream(destImageFile);
convert(read(srcImageFile), destExtName, imageOutputStream, StrUtil.equalsIgnoreCase(IMAGE_TYPE_PNG, srcExtName));
} finally {
IoUtil.close(imageOutputStream);
}
}
代码示例来源:origin: looly/hutool
/**
* 图像类型转换:GIF=》JPG、GIF=》PNG、PNG=》JPG、PNG=》GIF(X)、BMP=》PNG
*
* @param srcImageFile 源图像文件
* @param destImageFile 目标图像文件
*/
public static void convert(File srcImageFile, File destImageFile) {
Assert.notNull(srcImageFile);
Assert.notNull(destImageFile);
Assert.isFalse(srcImageFile.equals(destImageFile), "Src file is equals to dest file!");
final String srcExtName = FileUtil.extName(srcImageFile);
final String destExtName = FileUtil.extName(destImageFile);
if (StrUtil.equalsIgnoreCase(srcExtName, destExtName)) {
// 扩展名相同直接复制文件
FileUtil.copy(srcImageFile, destImageFile, true);
}
ImageOutputStream imageOutputStream = null;
try {
imageOutputStream = getImageOutputStream(destImageFile);
convert(read(srcImageFile), destExtName, imageOutputStream, StrUtil.equalsIgnoreCase(IMAGE_TYPE_PNG, srcExtName));
} finally {
IoUtil.close(imageOutputStream);
}
}
内容来源于网络,如有侵权,请联系作者删除!