Java Code Examples for org.apache.commons.collections4.CollectionUtils#isEmpty()
The following examples show how to use
org.apache.commons.collections4.CollectionUtils#isEmpty() .
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: CarreraConfiguration.java From DDMQ with Apache License 2.0 | 6 votes |
@Override public boolean validate() throws ConfigException { if (CollectionUtils.isEmpty(retryDelays)) { throw new ConfigException("[CarreraConfiguration] retryDelays empty"); } else if (thriftServer == null || !thriftServer.validate()) { throw new ConfigException("[CarreraConfiguration] thriftServer error"); } else if (useKafka && (kafkaProducers <= 0 || MapUtils.isEmpty(kafkaConfigurationMap) || !kafkaConfigurationMap.values().stream().allMatch(KafkaConfiguration::validate))) { throw new ConfigException("[CarreraConfiguration] kafka config error"); } else if (useRocketmq && (rocketmqProducers <= 0 || MapUtils.isEmpty(rocketmqConfigurationMap) || !rocketmqConfigurationMap.values().stream().allMatch(RocketmqConfiguration::validate))) { throw new ConfigException("[CarreraConfiguration] rocketmq config error"); } else if (useAutoBatch && (autoBatch == null || !autoBatch.validate())) { throw new ConfigException("[CarreraConfiguration] autoBatch error"); } else if (maxTps <= 0) { throw new ConfigException("[CarreraConfiguration] maxTps <= 0"); } else if (tpsWarningRatio <= 0) { throw new ConfigException("[CarreraConfiguration] tpsWarningRatio <= 0"); } else if (defaultTopicInfoConf == null) { throw new ConfigException("[CarreraConfiguration] defaultTopicInfoConf is null"); } return true; }
Example 2
Source File: StringUtils.java From FATE-Serving with Apache License 2.0 | 6 votes |
public static String join(Collection<String> coll, String split) { if (CollectionUtils.isEmpty(coll)) { return EMPTY; } StringBuilder sb = new StringBuilder(); boolean isFirst = true; for (String s : coll) { if (isFirst) { isFirst = false; } else { sb.append(split); } sb.append(s); } return sb.toString(); }
Example 3
Source File: PageInfo.java From spring-boot-plus with Apache License 2.0 | 6 votes |
/** * 如果是pageParam是OrderPageParam,并且不为空,则使用前端排序 * 否则使用默认排序 */ private void handle() { if (pageParam == null) { return; } // 设置pageIndex/pageSize super.setCurrent(pageParam.getPageIndex()); super.setSize(pageParam.getPageSize()); // 排序字段处理 BasePageOrderParam basePageOrderParam = (BasePageOrderParam) pageParam; List<OrderItem> orderItems = basePageOrderParam.getPageSorts(); if (CollectionUtils.isEmpty(orderItems)) { setDefaultOrder(defaultOrderItem); return; } if (orderMapping == null) { orderMapping = new OrderMapping(true); } orderMapping.filterOrderItems(orderItems); super.setOrders(orderItems); }
Example 4
Source File: UserModelEventListener.java From o2oa with GNU Affero General Public License v3.0 | 6 votes |
/** * 添加数据记录并检查是否换行 * @param row 实际当前行号 * @param col 实际记录当前列 * @param value 当前cell的值 */ public void addDataAndrChangeRow(int row,int col,Object value){ //当前行如果大于实际行表示改行忽略,不记录 if(curRowNum!=row){ if(CollectionUtils.isEmpty(currentSheetDataMap)){ currentSheetDataMap=new ArrayList<Map<String,Object>>(); } currentSheetDataMap.add(currentSheetRowDataMap); //logger.debug( "行号:"+curRowNum +" 行内容:"+currentSheetRowDataMap.toString()); //logger.debug( "\n" ); currentSheetRowDataMap=new HashMap<String,Object>(); currentSheetRowDataMap.put(trianListheadTitle[col], value); logger.debug(row+":"+col+" "+value+"\r" ); curRowNum=row; }else{ currentSheetRowDataMap.put(trianListheadTitle[col], value); //logger.debug(row+":"+col+" "+value+"\r" ); } }
Example 5
Source File: ControllerProcessor.java From AndServer with Apache License 2.0 | 6 votes |
@Override public boolean process(Set<? extends TypeElement> set, RoundEnvironment roundEnv) { if (CollectionUtils.isEmpty(set)) { return false; } Set<? extends Element> appSet = roundEnv.getElementsAnnotatedWith(AppInfo.class); String registerPackageName = getRegisterPackageName(appSet); Map<TypeElement, List<ExecutableElement>> controllers = new HashMap<>(); findMapping(roundEnv.getElementsAnnotatedWith(RequestMapping.class), controllers); findMapping(roundEnv.getElementsAnnotatedWith(GetMapping.class), controllers); findMapping(roundEnv.getElementsAnnotatedWith(PostMapping.class), controllers); findMapping(roundEnv.getElementsAnnotatedWith(PutMapping.class), controllers); findMapping(roundEnv.getElementsAnnotatedWith(PatchMapping.class), controllers); findMapping(roundEnv.getElementsAnnotatedWith(DeleteMapping.class), controllers); if (!controllers.isEmpty()) { createHandlerAdapter(registerPackageName, controllers); } return true; }
Example 6
Source File: AgentManageServiceImpl.java From DrivingAgency with MIT License | 6 votes |
@Override public List<AgentBaseInfoVo> listAllAgentsByDailyAchievements() { List<AgentVo> agentVos = listAllProcessedAgents(); List<AgentBaseInfoVo> collect =Lists.newArrayList(); if (CollectionUtils.isEmpty(agentVos)){ return null; } agentVos.stream() .filter(agentVo -> agentVo.getStatus().equals(AgentStatus.EXAMINED.getCode())) .sorted(Comparator.comparing(AgentVo::getDailyAchieve).reversed()) .forEach(agentVo -> { AgentBaseInfoVo agentBaseInfoVo=new AgentBaseInfoVo(); BeanUtils.copyProperties(agentVo,agentBaseInfoVo); collect.add(agentBaseInfoVo); }); return collect; }
Example 7
Source File: DataEngineSchemaTypeHandler.java From egeria with Apache License 2.0 | 6 votes |
private Set<String> getSchemaAttributesForSchemaType(String userId, String schemaTypeGUID) throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { final String methodName = "getSchemaAttributesForSchemaType"; invalidParameterHandler.validateUserId(userId, methodName); invalidParameterHandler.validateGUID(schemaTypeGUID, SchemaTypePropertiesMapper.GUID_PROPERTY_NAME, methodName); TypeDef relationshipTypeDef = repositoryHelper.getTypeDefByName(userId, SchemaElementMapper.TYPE_TO_ATTRIBUTE_RELATIONSHIP_TYPE_NAME); List<EntityDetail> entities = repositoryHandler.getEntitiesForRelationshipType(userId, schemaTypeGUID, SchemaElementMapper.SCHEMA_TYPE_TYPE_NAME, relationshipTypeDef.getGUID(), relationshipTypeDef.getName(), 0, 0, methodName); if (CollectionUtils.isEmpty(entities)) { return new HashSet<>(); } return entities.parallelStream().map(InstanceHeader::getGUID).collect(Collectors.toSet()); }
Example 8
Source File: DefaultBrowseService.java From archiva with Apache License 2.0 | 6 votes |
private List<String> getSelectedRepos( String repositoryId ) throws ArchivaRestServiceException { List<String> selectedRepos = getObservableRepos(); if ( CollectionUtils.isEmpty( selectedRepos ) ) { return Collections.emptyList(); } if ( StringUtils.isNotEmpty( repositoryId ) ) { // check user has karma on the repository if ( !selectedRepos.contains( repositoryId ) ) { throw new ArchivaRestServiceException( "browse.root.groups.repositoy.denied", Response.Status.FORBIDDEN.getStatusCode(), null ); } selectedRepos = Collections.singletonList( repositoryId ); } return selectedRepos; }
Example 9
Source File: MachineServiceImpl.java From zkdoctor with Apache License 2.0 | 5 votes |
@Override public boolean batchInsertNotExistsMachine(List<HostAndPort> hostAndPortList) { if (CollectionUtils.isEmpty(hostAndPortList)) { return false; } boolean result = true; for (HostAndPort hostAndPort : hostAndPortList) { if (!insertIfNotExistsMachine(hostAndPort.getHost())) { result = false; } } return result; }
Example 10
Source File: HttpSyncDataHandler.java From soul with Apache License 2.0 | 5 votes |
/** * Flush all plugin. If the collection is empty, the cache will be emptied. * * @param pluginDataList the plugin config */ public void flushAllPlugin(final List<PluginData> pluginDataList) { if (CollectionUtils.isEmpty(pluginDataList)) { log.info("clear all plugin data cache"); pluginDataSubscriber.refreshPluginData(); } else { pluginDataSubscriber.refreshPluginData(); pluginDataList.forEach(pluginDataSubscriber::onSubscribe); } }
Example 11
Source File: SysAuthorizeServiceImpl.java From cola-cloud with MIT License | 5 votes |
private boolean notExists(SysAuthorize authorize) { Wrapper<SysAuthorize> wrapper = new EntityWrapper<SysAuthorize>(); wrapper.eq("authorize_target", authorize.getAuthorizeTarget()); wrapper.eq("sys_role_id", authorize.getSysRoleId()); wrapper.eq("authorize_type", authorize.getAuthorizeType()); return CollectionUtils.isEmpty(this.selectList(wrapper)); }
Example 12
Source File: MetaIndexPO.java From youran with Apache License 2.0 | 5 votes |
public void resetFieldIds() { if (CollectionUtils.isEmpty(fields)) { this.fieldIds = Collections.emptyList(); } else { this.fieldIds = fields.stream() .map(MetaFieldPO::getFieldId) .collect(Collectors.toList()); } }
Example 13
Source File: MachineStateServiceImpl.java From zkdoctor with Apache License 2.0 | 5 votes |
@Override public boolean batchInsertMachineStateLogs(List<MachineStateLog> machineStateLogList) { if (CollectionUtils.isEmpty(machineStateLogList)) { return false; } return machineStateLogDao.batchInsertMachineStateLogs(machineStateLogList); }
Example 14
Source File: PermissionResourceServiceImpl.java From spring-boot-start-current with Apache License 2.0 | 5 votes |
private List< PermissionResourceVO > listByRolePermissionResource ( List< RolePermissionResource > rolePermissionResources ) { if ( CollectionUtils.isEmpty( rolePermissionResources ) ) { return Collections.emptyList(); } // 得到权限资源 final Collection< PermissionResource > permissionResources = super.listByIds( rolePermissionResources.parallelStream() .map( RolePermissionResource::getId ) .collect( Collectors.toList() ) ); if ( CollectionUtils.isEmpty( permissionResources ) ) { return Collections.emptyList(); } return this.tree( new ArrayList<>( permissionResources ) ); }
Example 15
Source File: KidozBidder.java From prebid-server-java with Apache License 2.0 | 5 votes |
private Imp validateImp(Imp imp) { if (imp.getBanner() == null && imp.getVideo() == null) { throw new PreBidException("Kidoz only supports banner or video ads"); } final Banner banner = imp.getBanner(); if (banner != null) { if (CollectionUtils.isEmpty(banner.getFormat())) { throw new PreBidException("banner format required"); } } return imp; }
Example 16
Source File: WebJavaScriptComponent.java From cuba with Apache License 2.0 | 5 votes |
@Override public void setDependencies(List<ClientDependency> dependencies) { if (CollectionUtils.isEmpty(dependencies)) { return; } List<HasDependencies.ClientDependency> vDependencies = new ArrayList<>(); for (ClientDependency dependency : dependencies) { Dependency.Type type = WebWrapperUtils.toVaadinDependencyType(dependency.getType()); vDependencies.add(new HasDependencies.ClientDependency(dependency.getPath(), type)); } component.setDependencies(vDependencies); }
Example 17
Source File: EplanningBidder.java From prebid-server-java with Apache License 2.0 | 5 votes |
@Override public Result<List<HttpRequest<Void>>> makeHttpRequests(BidRequest request) { final List<BidderError> errors = new ArrayList<>(); final List<String> requestsStrings = new ArrayList<>(); String clientId = null; for (final Imp imp : request.getImp()) { try { validateImp(imp); final ExtImpEplanning extImpEplanning = validateAndModifyImpExt(imp); if (clientId == null) { clientId = extImpEplanning.getClientId(); } final String sizeString = resolveSizeString(imp); final String name = getCleanAdUnitCode(extImpEplanning, () -> sizeString); requestsStrings.add(name + ":" + sizeString); } catch (PreBidException e) { errors.add(BidderError.badInput(e.getMessage())); } } if (CollectionUtils.isEmpty(requestsStrings)) { return Result.of(Collections.emptyList(), errors); } final MultiMap headers = createHeaders(request.getDevice()); final String uri = resolveRequestUri(request, requestsStrings, clientId); return Result.of(Collections.singletonList( HttpRequest.<Void>builder() .method(HttpMethod.GET) .uri(uri) .body(null) .headers(headers) .payload(null) .build()), errors); }
Example 18
Source File: AssetCatalogHandler.java From egeria with Apache License 2.0 | 4 votes |
private void getContextForFileFolder(String userId, EntityDetail entityDetail, AssetElement assetElement) throws UserNotAuthorizedException, PropertyServerException, InvalidParameterException { String method = "getContextForFileFolder"; List<EntityDetail> connections = repositoryHandler.getEntitiesForRelationshipType( userId, entityDetail.getGUID(), FILE_FOLDER, CONNECTION_TO_ASSET_GUID, CONNECTION_TO_ASSET, 0, 0, method); if (CollectionUtils.isNotEmpty(connections)) { setConnections(userId, assetElement, entityDetail); return; } List<Relationship> parentFolderRelationships = repositoryHandler.getRelationshipsByType(userId, entityDetail.getGUID(), entityDetail.getType().getTypeDefName(), FOLDER_HIERARCHY_GUID, FOLDER_HIERARCHY, method); if (CollectionUtils.isEmpty(parentFolderRelationships)) { return; } parentFolderRelationships = parentFolderRelationships.stream() .filter(s -> s.getEntityTwoProxy().getGUID().equals(entityDetail.getGUID())) .collect(Collectors.toList()); if (parentFolderRelationships.size() != 1) { return; } EntityProxy parentFolderProxy = repositoryHandler.getOtherEnd(entityDetail.getGUID(), parentFolderRelationships.get(0)); EntityDetail parentFolder = commonHandler.getEntityByGUID(userId, parentFolderProxy.getGUID(), parentFolderProxy.getType().getTypeDefName()); assetConverter.addElement(assetElement, parentFolder); getContextForFileFolder(userId, parentFolder, assetElement); }
Example 19
Source File: ControllerProcessor.java From AndServer with Apache License 2.0 | 4 votes |
private void createHandlerAdapter(String registerPackageName, Map<TypeElement, List<ExecutableElement>> controllers) { Map<String, List<String>> adapterMap = new HashMap<>(); for (Map.Entry<TypeElement, List<ExecutableElement>> entry : controllers.entrySet()) { TypeElement type = entry.getKey(); List<ExecutableElement> executes = entry.getValue(); mLog.i(String.format("------ Processing %s ------", type.getSimpleName())); String typeName = type.getQualifiedName().toString(); Mapping typeMapping = getTypeMapping(type); validateMapping(typeMapping, typeName); TypeName controllerType = TypeName.get(type.asType()); FieldSpec hostField = FieldSpec.builder(controllerType, "mHost", Modifier.PRIVATE).build(); FieldSpec mappingField = FieldSpec.builder(mMappingList, "mMappingMap", Modifier.PRIVATE).build(); CodeBlock.Builder rootCode = CodeBlock.builder() .addStatement("this.mHost = new $T()", type) .addStatement("this.mMappingMap = new $T<>()", LinkedHashMap.class); for (ExecutableElement execute : executes) { Mapping mapping = getExecuteMapping(execute); validateExecuteMapping(mapping, typeName + "#" + execute.getSimpleName().toString() + "()"); mapping = new Merge(typeMapping, mapping); rootCode.beginControlFlow("\n").addStatement("$T mapping = new $T()", mMapping, mMapping); addMapping(rootCode, mapping); Addition addition = execute.getAnnotation(Addition.class); rootCode.add("\n").addStatement("$T addition = new $T()", mAddition, mAddition); addAddition(rootCode, addition); String handlerName = createHandler(type, execute, mapping.path(), mapping.isRest()); rootCode.addStatement("$L handler = new $L(mHost, mapping, addition, $L)", handlerName, handlerName, mapping.isRest()).addStatement("mMappingMap.put(mapping, handler)").endControlFlow(); } MethodSpec rootMethod = MethodSpec.constructorBuilder() .addModifiers(Modifier.PUBLIC) .addCode(rootCode.build()) .build(); MethodSpec mappingMethod = MethodSpec.methodBuilder("getMappingMap") .addAnnotation(Override.class) .addModifiers(Modifier.PROTECTED) .returns(mMappingList) .addStatement("return mMappingMap") .build(); MethodSpec hostMethod = MethodSpec.methodBuilder("getHost") .addAnnotation(Override.class) .addModifiers(Modifier.PROTECTED) .returns(controllerType) .addStatement("return mHost") .build(); String adapterPackageName = getPackageName(type).getQualifiedName().toString(); String className = String.format("%sAdapter", type.getSimpleName()); TypeSpec adapterClass = TypeSpec.classBuilder(className) .addJavadoc(Constants.DOC_EDIT_WARN) .addModifiers(Modifier.PUBLIC, Modifier.FINAL) .superclass(mMappingAdapter) .addField(hostField) .addField(mappingField) .addMethod(rootMethod) .addMethod(mappingMethod) .addMethod(hostMethod) .build(); JavaFile javaFile = JavaFile.builder(adapterPackageName, adapterClass).build(); try { javaFile.writeTo(mFiler); } catch (IOException e) { throw new RuntimeException(e); } String group = getGroup(type); List<String> adapterList = adapterMap.get(group); if (CollectionUtils.isEmpty(adapterList)) { adapterList = new ArrayList<>(); adapterMap.put(group, adapterList); } adapterList.add(adapterPackageName + "." + className); } if (!adapterMap.isEmpty()) { createRegister(registerPackageName, adapterMap); } }
Example 20
Source File: BitmexContext.java From cryptotrader with GNU Affero General Public License v3.0 | 2 votes |
@Override public Map<CancelInstruction, String> cancelOrders(Key key, Set<CancelInstruction> instructions) { if (CollectionUtils.isEmpty(instructions)) { return Collections.emptyMap(); } Map<CancelInstruction, String> map = new IdentityHashMap<>(); try { String data = gson.toJson(singletonMap("clOrdID", instructions.stream() .filter(Objects::nonNull) .map(CancelInstruction::getId) .collect(toList()) )); String result = executePrivate(RequestType.DELETE, URL_ORDER, emptyMap(), data); List<BitmexOrder> results = gson.fromJson(result, TYPE_ORDER); instructions.stream().filter(Objects::nonNull).forEach(i -> { String id = results.stream() .filter(Objects::nonNull) .filter(o -> StringUtils.isNotEmpty(o.getClientId())) .filter(o -> StringUtils.equals(o.getClientId(), i.getId())) .map(BitmexOrder::getClientId) .findAny().orElse(null); map.put(i, id); }); } catch (Exception e) { log.warn("Order cancel failure : " + instructions, e); instructions.stream().filter(Objects::nonNull).forEach(i -> map.put(i, null)); } return map; }