org.apache.commons.collections4.CollectionUtils Java Examples
The following examples show how to use
org.apache.commons.collections4.CollectionUtils.
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: SubjectUtil.java From spring-microservice-exam with MIT License | 6 votes |
/** * 转换对象 * * @param subjectDtoList subjectDtoList * @return List */ public static List<SubjectExcelModel> convertToExcelModel(List<SubjectDto> subjectDtoList) { List<SubjectExcelModel> subjectExcelModels = new ArrayList<>(subjectDtoList.size()); subjectDtoList.forEach(subject -> { SubjectExcelModel subjectExcelModel = new SubjectExcelModel(); BeanUtils.copyProperties(subject, subjectExcelModel); if (CollectionUtils.isNotEmpty(subject.getOptions())) { List<String> optionString = subject.getOptions().stream() .map(option -> "$$" + option.getOptionName() + "# " + option.getOptionContent()).collect(Collectors.toList()); subjectExcelModel.setOptions(StringUtils.join(optionString, "\n")); } subjectExcelModel.setAnswer(subject.getAnswer().getAnswer()); subjectExcelModels.add(subjectExcelModel); }); return subjectExcelModels; }
Example #2
Source File: AppnexusBidder.java From prebid-server-java with Apache License 2.0 | 6 votes |
private static String makeKeywords(List<AppnexusKeyVal> keywords) { if (CollectionUtils.isEmpty(keywords)) { return null; } final List<String> kvs = new ArrayList<>(); for (AppnexusKeyVal keyVal : keywords) { final String key = keyVal.getKey(); final List<String> values = keyVal.getValue(); if (values == null || values.isEmpty()) { kvs.add(key); } else { for (String value : values) { kvs.add(String.format("%s=%s", key, value)); } } } return String.join(",", kvs); }
Example #3
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 #4
Source File: CollectionCompareTests.java From java_in_examples with Apache License 2.0 | 6 votes |
private static void testContainsAll() { Collection<String> collection1 = Lists.newArrayList("a1", "a2", "a3", "a1"); Collection<String> collection2 = Lists.newArrayList("a1", "a2", "a3", "a1"); Iterable<String> iterable1 = collection1; Iterable<String> iterable2 = collection2; MutableCollection<String> mutableCollection1 = FastList.newListWith("a1", "a2", "a3", "a1"); MutableCollection<String> mutableCollection2 = FastList.newListWith("a1", "a2", "a3", "a1"); // Check full equals with two collections boolean jdk = collection1.containsAll(collection2); // using JDK boolean guava = Iterables.elementsEqual(iterable1, iterable2); // using guava boolean apache = CollectionUtils.containsAll(collection1, collection2); // using Apache boolean gs = mutableCollection1.containsAll(mutableCollection2); // using GS System.out.println("containsAll = " + jdk + ":" + guava + ":" + apache + ":" + gs); // print containsAll = true:true:true:true }
Example #5
Source File: TreeUtil.java From youran with Apache License 2.0 | 6 votes |
/** * 根据父节点获取所有下级节点集合 * * @param t 父节点对象 * @param justLeaf 是否只采集叶子节点 * @param <T> 树节点泛型 * @return 子节点集合 */ public static <T extends TreeNode> Set<T> getChildSet(T t, boolean justLeaf) { List<T> children = t.fetchChildren(); if (CollectionUtils.isEmpty(children)) { return null; } Set<T> childSet = new HashSet<>(); for (T child : children) { TreeUtil.recurTreeNode(child, (t1, isLeaf) -> { //仅采集叶子的情况判断 if (justLeaf && !isLeaf) { return; } childSet.add(t1); }); } return childSet; }
Example #6
Source File: ConfigController.java From Thunder with Apache License 2.0 | 6 votes |
private static void assembleApplication(RegistryExecutor registryExecutor, ProtocolType protocolType, ElementNode root) throws Exception { ElementNode protocolNode = new ElementNode(protocolType.toString(), protocolType.toString(), null, protocolType.toString()); root.add(protocolNode); List<String> groups = null; try { groups = registryExecutor.getGroupList(); } catch (Exception e) { LOG.warn("Get group list failed, protocol={}", protocolType); } if (CollectionUtils.isNotEmpty(groups)) { for (String group : groups) { ElementNode groupNode = new ElementNode(protocolType.toString(), group, null, group); protocolNode.add(groupNode); List<String> applications = registryExecutor.getApplicationList(group); for (String application : applications) { ElementNode applicationNode = new ElementNode(protocolType.toString(), application, null, application); groupNode.add(applicationNode); } } } }
Example #7
Source File: BasicNeighborSolutionLocator.java From tabu with MIT License | 6 votes |
/** * Find the non-tabu {@link Solution} with the lowest value.<br> * This method doesn't use any Aspiration Criteria. */ @Override public Solution findBestNeighbor(List<Solution> neighborsSolutions, final List<Solution> solutionsInTabu) { //remove any neighbor that is in tabu list CollectionUtils.filterInverse(neighborsSolutions, new Predicate<Solution>() { @Override public boolean evaluate(Solution neighbor) { return solutionsInTabu.contains(neighbor); } }); //sort the neighbors Collections.sort(neighborsSolutions, new Comparator<Solution>() { @Override public int compare(Solution a, Solution b) { return a.getValue().compareTo(b.getValue()); } }); //get the neighbor with lowest value return neighborsSolutions.get(0); }
Example #8
Source File: TopicServiceImpl.java From DDMQ with Apache License 2.0 | 6 votes |
private Map<Long, TopicOrderVo> getTopicVoMap(List<Topic> list, List<CustomTopicConf> confList, Boolean needExtraParams) { Map<Long/*topicID*/, TopicOrderVo> topicVoMap = Maps.newLinkedHashMap(); list.forEach((topic -> { TopicOrderVo vo = TopicOrderVo.buildTopicVo(topic); topicVoMap.put(topic.getId(), vo); })); if (CollectionUtils.isNotEmpty(confList)) { Map<Long, Cluster> clusterMap = clusterService.findMap(); confList.forEach(conf -> { if (topicVoMap.containsKey(conf.getTopicId())) { try { TopicConfVo confVo = TopicConfVo.buildTopicConfVo(conf); confVo.setClusterDesc(clusterMap.get(conf.getClusterId()).getDescription()); topicVoMap.get(conf.getTopicId()).addConf(confVo); } catch (Exception e) { LOGGER.error("getTopicVoMap exception", e); } } }); } return topicVoMap; }
Example #9
Source File: MenuService.java From spring-microservice-exam with MIT License | 6 votes |
/** * 合并默认租户和租户的菜单,租户菜单优先 * * @param defaultMenus defaultMenus * @param tenantMenus tenantMenus * @return List * @author tangyi * @date 2019-09-14 14:45 */ private List<Menu> mergeMenu(List<Menu> defaultMenus, List<Menu> tenantMenus) { if (CollectionUtils.isEmpty(tenantMenus)) return defaultMenus; List<Menu> userMenus = new ArrayList<>(); // 默认菜单 defaultMenus.forEach(defaultMenu -> { Optional<Menu> menu = tenantMenus.stream() .filter(tenantMenu -> tenantMenu.getName().equals(defaultMenu.getName())).findFirst(); if (menu.isPresent()) { userMenus.add(menu.get()); } else { userMenus.add(defaultMenu); } }); // 租户菜单 tenantMenus.forEach(tenantMenu -> { Optional<Menu> exist = userMenus.stream() .filter(userMenu -> userMenu.getName().equals(tenantMenu.getName()) && userMenu.getParentId() .equals(tenantMenu.getParentId())).findFirst(); if (!exist.isPresent()) { userMenus.add(tenantMenu); } }); return userMenus; }
Example #10
Source File: VideoResponseFactory.java From prebid-server-java with Apache License 2.0 | 6 votes |
public VideoResponse toVideoResponse(BidRequest bidRequest, BidResponse bidResponse, List<PodError> podErrors) { final List<Bid> bids = bidsFrom(bidResponse); final boolean anyBidsReturned = CollectionUtils.isNotEmpty(bids); final List<ExtAdPod> adPods = adPodsWithTargetingFrom(bids); if (anyBidsReturned && CollectionUtils.isEmpty(adPods)) { throw new PreBidException("caching failed for all bids"); } adPods.addAll(adPodsWithErrors(podErrors)); final ExtResponseDebug extResponseDebug; final Map<String, List<ExtBidderError>> errors; // Fetch debug and errors information from response if requested if (isDebugEnabled(bidRequest)) { final ExtBidResponse extBidResponse = extResponseFrom(bidResponse); extResponseDebug = extResponseDebugFrom(extBidResponse); errors = errorsFrom(extBidResponse); } else { extResponseDebug = null; errors = null; } return VideoResponse.of(adPods, extResponseDebug, errors, null); }
Example #11
Source File: PublishConfigurationEntriesStep.java From multiapps-controller with Apache License 2.0 | 6 votes |
@Override protected StepPhase executeStep(ProcessContext context) { CloudApplicationExtended app = context.getVariable(Variables.APP_TO_PROCESS); getStepLogger().debug(MessageFormat.format(Messages.PUBLISHING_PUBLIC_PROVIDED_DEPENDENCIES, app.getName())); List<ConfigurationEntry> entriesToPublish = context.getVariable(Variables.CONFIGURATION_ENTRIES_TO_PUBLISH); if (CollectionUtils.isEmpty(entriesToPublish)) { context.setVariable(Variables.PUBLISHED_ENTRIES, Collections.emptyList()); getStepLogger().debug(Messages.NO_PUBLIC_PROVIDED_DEPENDENCIES_FOR_PUBLISHING); return StepPhase.DONE; } List<ConfigurationEntry> publishedEntries = publish(entriesToPublish); getStepLogger().debug(Messages.PUBLISHED_ENTRIES, SecureSerialization.toJson(publishedEntries)); context.setVariable(Variables.PUBLISHED_ENTRIES, publishedEntries); getStepLogger().debug(Messages.PUBLIC_PROVIDED_DEPENDENCIES_PUBLISHED); return StepPhase.DONE; }
Example #12
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 #13
Source File: SettingsWindow.java From cuba with Apache License 2.0 | 6 votes |
protected List<MenuItem> collectPermittedScreens(List<MenuItem> menuItems) { List<MenuItem> collectedItems = new ArrayList<>(); for (MenuItem item : menuItems) { if (!item.isPermitted(userSession)) continue; if (StringUtils.isNotEmpty(item.getScreen())) { collectedItems.add(item); } if (CollectionUtils.isNotEmpty(item.getChildren())) { collectedItems.addAll(collectPermittedScreens(item.getChildren())); } } return collectedItems; }
Example #14
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 #15
Source File: ClouderaManagerClusterCreationSetupService.java From cloudbreak with Apache License 2.0 | 6 votes |
private List<ClusterComponent> determineCdhRepoConfig(Cluster cluster, List<Component> stackCdhRepoConfig, String osType, String blueprintCdhVersion) { if (Objects.isNull(stackCdhRepoConfig) || stackCdhRepoConfig.isEmpty()) { DefaultCDHInfo defaultCDHInfo = getDefaultCDHInfo(blueprintCdhVersion, osType); Map<String, String> stack = defaultCDHInfo.getRepo().getStack(); ClouderaManagerProduct cmProduct = new ClouderaManagerProduct() .withVersion(defaultCDHInfo.getVersion()) .withName(stack.get("repoid").split("-")[0]) .withParcel(stack.get(osType)); List<ClouderaManagerProduct> products = CollectionUtils.isNotEmpty(defaultCDHInfo.getParcels()) ? defaultCDHInfo.getParcels() : new ArrayList<>(); products.add(cmProduct); return products.stream().map(product -> new ClusterComponent(CDH_PRODUCT_DETAILS, product.getName(), new Json(product), cluster)) .collect(Collectors.toList()); } else { return stackCdhRepoConfig.stream() .map(Component::getAttributes) .map(json -> new ClusterComponent(CDH_PRODUCT_DETAILS, json.getSilent(ClouderaManagerProduct.class).getName(), json, cluster)) .collect(Collectors.toList()); } }
Example #16
Source File: SendingMessageBrowser.java From cuba with Apache License 2.0 | 5 votes |
public void download() { SendingMessage message = table.getSingleSelected(); if (message != null) { List<SendingAttachment> attachments = getAttachments(message); if (CollectionUtils.isNotEmpty(attachments)) { if (attachments.size() == 1) { exportFile(attachments.get(0)); } else { selectAttachmentDialog(message); } } else { showNotification(messages.getMessage(getClass(), "sendingMessage.noAttachments"), NotificationType.HUMANIZED); } } }
Example #17
Source File: ImageBuilder.java From docker-image-builder with Apache License 2.0 | 5 votes |
public ImageBuilder withRunScript(Script runScript) { if(CollectionUtils.isEmpty(this.runScript)) { this.runScript = new ArrayList<>(); } this.runScript.add(runScript); return this; }
Example #18
Source File: Business.java From o2oa with GNU Affero General Public License v3.0 | 5 votes |
public boolean readable(EffectivePerson effectivePerson, Stat stat) throws Exception { if (null == stat) { return false; } if (effectivePerson.isManager()) { return true; } if (stat.getAvailableIdentityList().isEmpty() && stat.getAvailableUnitList().isEmpty()) { return true; } if (CollectionUtils.containsAny(stat.getAvailableIdentityList(), organization().identity().listWithPerson(effectivePerson))) { return true; } if (CollectionUtils.containsAny(stat.getAvailableUnitList(), organization().unit().listWithPersonSupNested(effectivePerson))) { return true; } Query query = this.entityManagerContainer().find(stat.getQuery(), Query.class); /** 在所属query的管理人员中 */ if (null != query && ListTools.contains(query.getControllerList(), effectivePerson.getDistinguishedName())) { return true; } if (organization().person().hasRole(effectivePerson, OrganizationDefinition.Manager, OrganizationDefinition.QueryManager)) { return true; } return false; }
Example #19
Source File: WeeklyReportEntry.java From sample-timesheets with Apache License 2.0 | 5 votes |
protected HoursAndMinutes getTotalForTimeEntries(List<TimeEntry> timeEntries) { HoursAndMinutes total = new HoursAndMinutes(); if (CollectionUtils.isNotEmpty(timeEntries)) { for (TimeEntry timeEntry : timeEntries) { Integer timeInMinutes = timeEntry.getTimeInMinutes(); if (timeInMinutes != null) { total.addMinutes(timeInMinutes); } } } return total; }
Example #20
Source File: CarreraOffsetManager.java From DDMQ with Apache License 2.0 | 5 votes |
private void logConsumeOffset() { long startTime = TimeUtils.getCurTime(); if (CollectionUtils.isEmpty(consumers)) return; List<OffsetTrackSnapshot> offsetTrackSnapshots = buildOffsetTrackSnapshotTable(); for (OffsetTrackSnapshot snapshot : offsetTrackSnapshots) { long maxOffset = snapshot.getMaxOffset(); long start = snapshot.getStartConsumeOffset(); long finish = snapshot.getFinishConsumeOffset(); long commitable = snapshot.getMaxCommittableOffset(); long committed = snapshot.getCommittedOffset(); long fetchLag = (maxOffset > 0 && start > 0) ? Math.max(0, maxOffset - start) : 0; long commitableLag = finish > 0 ? (commitable > 0 ? Math.max(0, finish - commitable) : Math.max(0, finish - committed)) : 0; long committedLag = (maxOffset > 0 && committed > 0) ? Math.max(0, maxOffset - committed) : 0; long consumeLag = (finish > 0 && maxOffset > 0) ? Math.max(0, maxOffset - finish) : committedLag; OFFSET_LOGGER.info("group={},snapshot={}", snapshot.getGroup(), snapshot); String groupTopic = snapshot.getGroup() + "-" + snapshot.getTopic(); MetricUtils.maxOffsetCount(snapshot.getGroup(), snapshot.getTopic(), snapshot.getQid(), "committed", snapshot.getCommittedOffset()); MetricUtils.maxOffsetCount(snapshot.getGroup(), snapshot.getTopic(), snapshot.getQid(), "consume", snapshot.getFinishConsumeOffset()); MetricUtils.maxOffsetCount(snapshot.getGroup(), snapshot.getTopic(), snapshot.getQid(), "produce", snapshot.getMaxOffset()); MetricUtils.maxOffsetCount(snapshot.getGroup(), snapshot.getTopic(), snapshot.getQid(), "commitable", snapshot.getMaxCommittableOffset()); MetricUtils.maxOffsetLagCount(snapshot.getGroup(), snapshot.getTopic(), snapshot.getQid(), "fetchLag", fetchLag); OFFSET_LOGGER.info("groupId-topic={},qid={},fetchLag={}", groupTopic, snapshot.getQid(), fetchLag); MetricUtils.maxOffsetLagCount(snapshot.getGroup(), snapshot.getTopic(), snapshot.getQid(), "commitableLag", commitableLag); OFFSET_LOGGER.info("groupId-topic={},qid={},commitableLag={}", groupTopic, snapshot.getQid(), commitableLag); MetricUtils.maxOffsetLagCount(snapshot.getGroup(), snapshot.getTopic(), snapshot.getQid(), "commitLag", committedLag); OFFSET_LOGGER.info("groupId-topic={},qid={},commitLag={}", groupTopic, snapshot.getQid(), committedLag); MetricUtils.maxOffsetLagCount(snapshot.getGroup(), snapshot.getTopic(), snapshot.getQid(), "consumeLag", consumeLag); OFFSET_LOGGER.info("groupId-topic={},qid={},consumeLag={}", groupTopic, snapshot.getQid(), consumeLag); } LOGGER.info("logConsumeOffset finished, cost={}ms", TimeUtils.getElapseTime(startTime)); }
Example #21
Source File: RankingAndDirScoreSelection.java From jMetal with MIT License | 5 votes |
@Override public List<S> execute(List<S> solutionSet) { if (referenceVectors == null || referenceVectors.length == 0) { throw new JMetalException("reference vectors can not be null."); } if (CollectionUtils.isEmpty(solutionSet)) { throw new JMetalException("solution set can not be null"); } Ranking<S> ranking = new DominanceRanking<>(dominanceComparator); ranking.computeRanking(solutionSet); return dirScoreSelection(ranking); }
Example #22
Source File: WebOptionsList.java From cuba with Apache License 2.0 | 5 votes |
protected boolean equalCollections(Collection<V> a, Collection<V> b) { if (a == null && b == null) { return true; } if (a == null || b == null) { return false; } return CollectionUtils.isEqualCollection(a, b); }
Example #23
Source File: NERParserCommon.java From grobid-ner with Apache License 2.0 | 5 votes |
private OffsetPosition calculateOffsets(TaggingTokenCluster cluster) { final List<LabeledTokensContainer> labeledTokensContainers = cluster.getLabeledTokensContainers(); if (CollectionUtils.isEmpty(labeledTokensContainers) || CollectionUtils.isEmpty(labeledTokensContainers.get(0).getLayoutTokens())) { return new OffsetPosition(); } final LabeledTokensContainer labeledTokensContainer = labeledTokensContainers.get(0); final List<LayoutToken> layoutTokens = labeledTokensContainer.getLayoutTokens(); int start = layoutTokens.get(0).getOffset(); int end = start + LayoutTokensUtil.normalizeText(LayoutTokensUtil.toText(cluster.concatTokens())).length(); return new OffsetPosition(start, end); }
Example #24
Source File: WebServiceMonitorExecutor.java From Thunder with Apache License 2.0 | 5 votes |
@Override public void execute(MonitorStat monitorStat) throws Exception { MonitorEntity monitorEntity = cacheContainer.getMonitorEntity(); List<String> addresses = monitorEntity.getAddresses(); if (CollectionUtils.isEmpty(addresses)) { LOG.error("Webservice monitor addresses are null"); return; } for (String address : addresses) { if (!address.startsWith("http://")) { address = "http://" + address; } String value = SerializerExecutor.toJson(monitorStat); HttpEntity entity = new StringEntity(value, ThunderConstant.ENCODING_UTF_8); HttpPost httpPost = new HttpPost(address); httpPost.addHeader("content-type", "application/json;charset=" + ThunderConstant.ENCODING_UTF_8); httpPost.setEntity(entity); HttpAsyncCallback httpAsyncCallback = new HttpAsyncCallback(); httpAsyncCallback.setHttpPost(httpPost); httpAsyncClient.execute(httpPost, httpAsyncCallback); } }
Example #25
Source File: JobExecLogH2DaoImpl.java From chronus with Apache License 2.0 | 5 votes |
private List<JobExecLogEntity> transferEntityList(List<JobExecLogH2Entity> h2Entity) { if (CollectionUtils.isEmpty(h2Entity)) { return new ArrayList<>(); } return h2Entity.stream() .map(this::transferEntity) .collect(Collectors.toList()); }
Example #26
Source File: StudioNodeActivityCheckJob.java From studio with GNU General Public License v3.0 | 5 votes |
private void removeInactiveMembers(List<ClusterMember> inactiveMembersToRemove) { List<Long> idsToRemove = inactiveMembersToRemove.stream() .map(ClusterMember::getId) .collect(Collectors.toList()); if (CollectionUtils.isNotEmpty(idsToRemove)) { Map<String, Object> params = new HashMap<String, Object>(); params.put(CLUSTER_MEMBER_IDS, idsToRemove); params.put(CLUSTER_INACTIVE_STATE, INACTIVE); int result = clusterDao.removeMembers(params); } }
Example #27
Source File: ObaAisConsentMapper.java From XS2A-Sandbox with Apache License 2.0 | 5 votes |
private String resolveUserId(List<PsuIdData> psuIdDataList) { if (CollectionUtils.isEmpty(psuIdDataList)) { return null; } return getFirstPsu(psuIdDataList) .getPsuId(); }
Example #28
Source File: InstanceServiceImplTest.java From zkdoctor with Apache License 2.0 | 5 votes |
@Test public void testGetInstancesByClusterId() throws Exception { List<InstanceInfo> instanceInfoList = instanceService.getInstancesByClusterId(1); if (CollectionUtils.isNotEmpty(instanceInfoList)) { for (InstanceInfo instanceInfo : instanceInfoList) { System.out.println(instanceInfo); } } else { System.out.println("Result is empty."); } }
Example #29
Source File: NerdEntity.java From entity-fishing with Apache License 2.0 | 5 votes |
public void setWikipediaMultilingualRef(Map<String,String> translations, List<String> targetLanguages, Map<String, LowerKnowledgeBase> wikipedias) { if (CollectionUtils.isEmpty (targetLanguages) ) { return; } Map<String,String> subTranslations = new TreeMap<>(); Map<String,Integer> subArticleCorrespondance = new TreeMap<>(); for(String targetLanguage : targetLanguages) { String translation = translations.get(targetLanguage); if (translation != null) { int ind = translation.indexOf("#"); if (ind != -1) { translation = translation.substring(0,ind); } translation = translation.replace("\\'", "'"); // TODO: translation is html encoded, should be decoded in a standard manner translation = translation.replace("%2C", ","); subTranslations.put(targetLanguage, translation); if (wikipedias.get(targetLanguage) != null) { Article article = wikipedias.get(targetLanguage).getArticleByTitle(translation); if (article != null) { subArticleCorrespondance.put(targetLanguage, article.getId()); } else { LOGGER.warn("Lookup translation: " +translation + ": Article for language " + targetLanguage + " is null. Ignoring it."); } } else { LOGGER.warn("Lookup translations: No Knowledge base available for language " + targetLanguage + "."); } } } wikipediaMultilingualRef = subTranslations; wikipediaMultilingualArticle = subArticleCorrespondance; }
Example #30
Source File: ConsentMapper.java From XS2A-Sandbox with Apache License 2.0 | 5 votes |
private List<AccountReference> toAccountReferences(List<AccountReferenceInfo> source) { if (CollectionUtils.isNotEmpty(source)) { return source.stream() .map(r -> new AccountReference( AccountReferenceType.valueOf(r.getAccountType().name()), r.getAccountIdentifier(), Currency.getInstance(r.getCurrency()), r.getResourceId(), r.getAspspAccountId())) .collect(Collectors.toList()); } return Collections.emptyList(); }