Java Code Examples for cn.hutool.core.lang.Assert#isTrue()

The following examples show how to use cn.hutool.core.lang.Assert#isTrue() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServerBootstrap.java    From bitchat with Apache License 2.0 5 votes vote down vote up
public void start(Integer serverPort) {
    ServerFactory factory = SimpleServerFactory.getInstance();
    Server server;
    if (ServerMode.STAND_ALONE == serverMode) {
        server = factory.newServer(serverPort, channelListener);
    } else {
        Assert.notNull(routerServerAttr, "routerServerAttr can not be null cause you are starting the server in cluster mode");
        Assert.isTrue(routerServerAttr.valid(), "routerServerAttr is invalid");
        server = factory.newClusterServer(serverPort, channelListener, routerServerAttr);
    }
    server.start();
}
 
Example 2
Source File: SchemeResource.java    From albedo with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Log(value = "方案生成代码")
@PutMapping(value = "/gen-code")
@PreAuthorize("@pms.hasPermission('gen_scheme_code')")
public Result genCode(@Valid @RequestBody GenCodeDto genCodeDto) {
	SchemeDto genSchemeDto = schemeService.getOneDto(genCodeDto.getId());
	Assert.isTrue(genSchemeDto != null, "无法获取代码生成方案信息");
	genSchemeDto.setReplaceFile(genCodeDto.getReplaceFile());
	schemeService.generateCode(genSchemeDto);
	return Result.buildOk("生成", genSchemeDto.getName(), "代码成功");
}
 
Example 3
Source File: UserDetailsServiceImpl.java    From albedo with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * 用户密码登录
 *
 * @param username 用户名
 * @return
 */
@Override
@SneakyThrows
public UserDetails loadUserByUsername(String username) {
	UserVo userVo = userService.findVoByUsername(username);
	if (userVo == null) {
		throw new UsernameNotFoundException("用户不存在");
	}
	Assert.isTrue(userVo.isAvailable(), "用户【" + username + "】已被锁定,无法登录");
	UserDetails userDetails = getUserDetails(userService.getInfo(userVo));
	return userDetails;
}