use of cn.hutool.core.exceptions.NotInitedException in project hutool by looly.
the class MongoDS method createServerAddress.
// --------------------------------------------------------------------------- Private method start
/**
* 创建ServerAddress对象,会读取配置文件中的相关信息
*
* @param group 分组,如果为{@code null}或者""默认为无分组
* @return ServerAddress
*/
private ServerAddress createServerAddress(String group) {
final Setting setting = checkSetting();
if (group == null) {
group = StrUtil.EMPTY;
}
final String tmpHost = setting.getByGroup("host", group);
if (StrUtil.isBlank(tmpHost)) {
throw new NotInitedException("Host name is empy of group: {}", group);
}
final int defaultPort = setting.getInt("port", group, 27017);
return new ServerAddress(NetUtil.buildInetSocketAddress(tmpHost, defaultPort));
}
Aggregations