private void parseList(String value, Set<String> set) { if (Objects.nonNull(value)) { set.addAll(Arrays.asList(value.split(" "))); } } }
private void parseList(String value, Set<String> set) { if (Objects.nonNull(value)) { set.addAll(Arrays.asList(value.split(" "))); } } }
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; } }
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))); }
/** * 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)); }
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(", ")); }
@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); } }
private boolean isValidItem(ItemDTO item) { return Objects.nonNull(item) && !StringUtils.isContainEmpty(item.getKey()); }
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()); }
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 ); }
public void await() { if (Objects.nonNull(rpcContent.getRes())) { return; } rpcContent.await(); }
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() ) ); }
@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); } }
/** * 根据实体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())); } }
@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); } }
@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; }
/** * Common Assertion * @param h2it target iterator */ private void checkIterator(H2ResultSetIterator h2it){ if (Objects.nonNull(h2it)) assertNull(GridTestUtils.getFieldValue(h2it, H2ResultSetIterator.class, "data")); else fail(); }
@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); } }
@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); } }
@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)); }