本文整理了Java中java.util.Objects.nonNull()
方法的一些代码示例,展示了Objects.nonNull()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Objects.nonNull()
方法的具体详情如下:
包路径:java.util.Objects
类名称:Objects
方法名:nonNull
[英]Returns true if the provided reference is non- nullotherwise returns false.
[中]如果提供的引用为非null,则返回true,否则返回false。
代码示例来源:origin: apache/flume
private void parseList(String value, Set<String> set) {
if (Objects.nonNull(value)) {
set.addAll(Arrays.asList(value.split(" ")));
}
}
}
代码示例来源:origin: apache/flume
private void parseList(String value, Set<String> set) {
if (Objects.nonNull(value)) {
set.addAll(Arrays.asList(value.split(" ")));
}
}
}
代码示例来源:origin: hs-web/hsweb-framework
public static DatabaseType fromJdbcUrl(String url) {
if (Objects.nonNull(url)) {
return Arrays.stream(values()).filter(type -> type.urlPredicate.test(url)).findFirst().orElse(unknown);
}
return unknown;
}
}
代码示例来源:origin: SonarSource/sonarqube
private void validatePullRequestParamsWhenPluginAbsent(List<String> validationMessages) {
Stream.of(PULL_REQUEST_KEY, PULL_REQUEST_BRANCH, PULL_REQUEST_BASE)
.filter(param -> nonNull(settings.get(param).orElse(null)))
.forEach(param -> validationMessages.add(format("To use the property \"%s\", the branch plugin is required but not installed. "
+ "See the documentation of branch support: %s.", param, BRANCHES_DOC_LINK)));
}
代码示例来源:origin: apache/storm
/**
* Retrieve the set of alive worker IDs.
*
* @param nowSecs current time in seconds
*/
public Set<String> getAliveIds(int nowSecs) {
return SupervisorUtils.readWorkerHeartbeats(stormConf).entrySet().stream()
.filter(entry -> Objects.nonNull(entry.getValue())
&& !SupervisorUtils.isWorkerHbTimedOut(nowSecs, entry.getValue(), stormConf))
.map(Map.Entry::getKey)
.collect(toCollection(TreeSet::new));
}
代码示例来源:origin: wildfly/wildfly
public String printLocks() {
return table.values().stream().map(Map::values).flatMap(Collection::stream)
.filter(cl -> cl.isHeld() && Objects.nonNull(cl.name))
.map(cl -> cl.name).collect(Collectors.joining(", "));
}
代码示例来源:origin: codingapi/tx-lcn
@Override
public void stopDelayChecking(String groupId, String unitId) {
ScheduledFuture scheduledFuture = delayTasks.get(groupId + unitId);
if (Objects.nonNull(scheduledFuture)) {
txLogger.trace(groupId, unitId, Transactions.TAG_TASK, "stop delay checking task");
log.debug("cancel {}:{} checking.", groupId, unitId);
scheduledFuture.cancel(true);
}
}
代码示例来源:origin: ctripcorp/apollo
private boolean isValidItem(ItemDTO item) {
return Objects.nonNull(item) && !StringUtils.isContainEmpty(item.getKey());
}
代码示例来源:origin: MovingBlocks/Terasology
private Set<Module> getAllModuleDependencies(final Collection<Module> modules) {
return modules.stream()
.filter(Objects::nonNull)
.map(Module::getMetadata)
.map(ModuleMetadata::getDependencies)
.flatMap(Collection::stream)
.filter(dep -> Objects.nonNull(dep.getId()))
.map(dep -> moduleManager.getRegistry().getLatestModuleVersion(dep.getId()))
.filter(Objects::nonNull)
.collect(Collectors.toSet());
}
代码示例来源:origin: pentaho/pentaho-kettle
public TabMapEntry findTabMapEntry( Object managedObject ) {
if ( managedObject == null ) {
return null;
}
return tabMap.stream()
.filter( tabMapEntry -> !tabMapEntry.getTabItem().isDisposed() )
.filter( tabMapEntry -> Objects.nonNull( tabMapEntry.getObject().getManagedObject() ) )
// make sure they are the same class before comparing them
.filter( tabMapEntry -> tabMapEntry.getObject().getManagedObject().getClass().equals( managedObject.getClass() ) )
.filter( tabMapEntry -> tabMapEntry.getObject().getManagedObject().equals( managedObject ) )
.findFirst().orElse( null );
}
代码示例来源:origin: codingapi/tx-lcn
public void await() {
if (Objects.nonNull(rpcContent.getRes())) {
return;
}
rpcContent.await();
}
代码示例来源:origin: pentaho/pentaho-kettle
private boolean sameId( RemoteSource source1, RemoteSource source2 ) {
return ( Objects.isNull( source1.getId() ) && Objects.isNull( source2.getId() ) )
|| ( Objects.nonNull( source1.getId() ) && source1.getId().equals( source2.getId() ) );
}
代码示例来源:origin: ctripcorp/apollo
@Transactional
public void deleteApp(App app, String operator) {
String appId = app.getAppId();
logger.info("{} is deleting App:{}", operator, appId);
List<Cluster> managedClusters = clusterService.findClusters(appId);
// 1. delete clusters
if (Objects.nonNull(managedClusters)) {
for (Cluster cluster : managedClusters) {
clusterService.delete(cluster.getId(), operator);
}
}
// 2. delete appNamespace
appNamespaceService.batchDelete(appId, operator);
// 3. delete app
appService.delete(app.getId(), operator);
}
}
代码示例来源:origin: baomidou/mybatis-plus
/**
* 根据实体FieldStrategy属性来决定判断逻辑
*/
private boolean fieldStrategyMatch(T entity, TableFieldInfo e) {
switch (e.getFieldStrategy()) {
case NOT_NULL:
return Objects.nonNull(ReflectionKit.getMethodValue(entity, e.getProperty()));
case IGNORED:
return true;
case NOT_EMPTY:
return StringUtils.checkValNotNull(ReflectionKit.getMethodValue(entity, e.getProperty()));
default:
return Objects.nonNull(ReflectionKit.getMethodValue(entity, e.getProperty()));
}
}
代码示例来源:origin: codingapi/tx-lcn
@Override
public void add(String token) {
Objects.requireNonNull(token);
Long size = redisTemplate.opsForList().size(REDIS_PREFIX);
redisTemplate.opsForList().leftPush(REDIS_PREFIX, token);
redisTemplate.expire(REDIS_PREFIX, 20, TimeUnit.MINUTES);
if (Objects.nonNull(size) && size > 3) {
redisTemplate.opsForList().rightPop(REDIS_PREFIX);
}
}
代码示例来源:origin: baomidou/mybatis-plus
@Override
public String getCustomSqlSegment() {
MergeSegments expression = getExpression();
if (Objects.nonNull(expression)) {
NormalSegmentList normal = expression.getNormal();
String sqlSegment = getSqlSegment();
if (StringUtils.isNotEmpty(sqlSegment)) {
if (normal.isEmpty()) {
return sqlSegment;
} else {
return concatWhere(sqlSegment);
}
}
}
return StringUtils.EMPTY;
}
代码示例来源:origin: apache/ignite
/**
* Common Assertion
* @param h2it target iterator
*/
private void checkIterator(H2ResultSetIterator h2it){
if (Objects.nonNull(h2it))
assertNull(GridTestUtils.getFieldValue(h2it, H2ResultSetIterator.class, "data"));
else
fail();
}
代码示例来源:origin: yu199195/hmily
@SuppressWarnings("unchecked")
private void executeParticipantMethod(final HmilyInvocation hmilyInvocation) throws Exception {
if (Objects.nonNull(hmilyInvocation)) {
final Class clazz = hmilyInvocation.getTargetClass();
final String method = hmilyInvocation.getMethodName();
final Object[] args = hmilyInvocation.getArgs();
final Class[] parameterTypes = hmilyInvocation.getParameterTypes();
final Object bean = SpringBeanUtils.getInstance().getBean(clazz);
MethodUtils.invokeMethod(bean, method, args, parameterTypes);
}
}
代码示例来源:origin: codingapi/tx-lcn
@Override
public void postBusinessCode(TxTransactionInfo info) {
RollbackInfo rollbackInfo = (RollbackInfo) DTXLocal.cur().getAttachment();
int state = DTXLocal.transactionState();
// 非成功状态。(事务导致){#link TxcServiceImpl.lockResource}
if (Objects.nonNull(rollbackInfo) && rollbackInfo.getStatus() < 0) {
state = -1;
}
// 关闭事务组
transactionControlTemplate.notifyGroup(info.getGroupId(), info.getUnitId(), info.getTransactionType(), state);
}
}
代码示例来源:origin: yu199195/hmily
@Override
public void apply(final RequestTemplate requestTemplate) {
final HmilyTransactionContext hmilyTransactionContext = HmilyTransactionContextLocal.getInstance().get();
if (Objects.nonNull(hmilyTransactionContext)) {
if (hmilyTransactionContext.getRole() == HmilyRoleEnum.LOCAL.getCode()) {
hmilyTransactionContext.setRole(HmilyRoleEnum.INLINE.getCode());
}
}
requestTemplate.header(CommonConstant.HMILY_TRANSACTION_CONTEXT, GsonUtils.getInstance().toJson(hmilyTransactionContext));
}
内容来源于网络,如有侵权,请联系作者删除!