本文整理汇总了Java中org.apache.commons.collections4.CollectionUtils.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java CollectionUtils.isEmpty方法的具体用法?Java CollectionUtils.isEmpty怎么用?Java CollectionUtils.isEmpty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.collections4.CollectionUtils
的用法示例。
在下文中一共展示了CollectionUtils.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findApplicationFromVm
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
* Gets the applicationVm's persisted application record. (Currently require exactly 1.)
*/
private Application findApplicationFromVm(ApplicationVm applicationVm)
{
List<Application> applications = applicationVm.getApplications();
if (CollectionUtils.isEmpty(applications))
{
throw new IllegalStateException(context(applicationVm.getEnvironment()) + "No application");
}
else
{
if (applications.size() > 1)
{
throw new UnsupportedOperationException(context(applicationVm.getEnvironment())
+ "Currently only support case of 1 application, but applicationVm '"
+ applicationVm.getHostname() + "' has " + applications.size());
}
return applications.get(0);
}
}
示例2: findLogicalDatabaseFromEnvironment
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
* Gets the env's persisted logicaldb record. Requires exactly 1.
*/
private LogicalDatabase findLogicalDatabaseFromEnvironment(Environment environment)
{
List<LogicalDatabase> logicalDatabases = environment.getLogicalDatabases();
if (CollectionUtils.isEmpty(logicalDatabases))
{
throw new IllegalStateException(context(environment) + "No logical databases");
}
else if (logicalDatabases.size() > 1)
{
throw new UnsupportedOperationException(context(environment) + "Currently only support case of 1 logicalDatabase, but live env has "
+ logicalDatabases.size()); // + ": " + listOfNames(logicalDatabases));
}
else if (StringUtils.isBlank(logicalDatabases.get(0).getLogicalName()))
{
throw new IllegalStateException(context(environment) + "Logical database has blank name");
}
return logicalDatabases.get(0);
}
示例3: loadCdsNucleatides
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
private List<List<Sequence>> loadCdsNucleatides(List<Gene> cdsList, long referenceId, Chromosome chromosome) {
if (CollectionUtils.isEmpty(cdsList)) {
return null;
}
// Load reference nucleotides for CDS.
List<List<Sequence>> cdsNucleotides;
try {
cdsNucleotides = loadNucleotidesForReferenceCds(chromosome, referenceId, cdsList);
} catch (IOException e) {
LOGGER.error("Error during protein sequence reconstruction.", e);
return null;
}
Assert.notNull(cdsNucleotides, "Cannot load nucleotides for cds list.");
return cdsNucleotides;
}
示例4: verifyAndUpdateJvmStates
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
@Override
@Scheduled(fixedDelayString = "${ping.jvm.period.millis}")
public void verifyAndUpdateJvmStates() {
final List<Jvm> jvms = jvmPersistenceService.getJvms();
if (CollectionUtils.isEmpty(jvms)) {
LOGGER.warn("No JVMs found to ping.");
return;
}
for (final Jvm jvm : jvms) {
if (stateNotInMemory(jvm) || isValidState(jvm) && isFutureNilOrDone(jvm) && isStale(jvm)) {
LOGGER.debug("Pinging JVM {} ...", jvm.getJvmName());
PING_FUTURE_MAP.put(jvm.getId(), jvmStateResolverWorker.pingAndUpdateJvmState(jvm, this));
LOGGER.debug("Pinged JVM {}", jvm.getJvmName());
}
}
}
示例5: getTemplatesPatterns
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
private List<PatternModel> getTemplatesPatterns(Resource resource, String patternsPath, String patternId,
List<String> templateNames) throws IOException {
List<PatternModel> templatesPatterns = Lists.newArrayList();
final Resource folderResource = resource.getParent();
final List<String> jsonDataFiles = retrieveJsonDataFilesInFolder(folderResource, StringUtils.substringBefore(resource.getName(), PatternLabConstants.HTML_EXT));
for (String templateName : templateNames) {
final List<String> templateDedicatedDataFiles = getTemplateDedicatedFiles(templateName, jsonDataFiles, templateNames);
if (CollectionUtils.isEmpty(templateDedicatedDataFiles)) {
templatesPatterns.add(new PatternModel(resource, patternsPath, patternId, StringUtils.EMPTY, templateName, this.resourceResolver));
} else {
for (String jsonDataFileName : templateDedicatedDataFiles) {
templatesPatterns.add(new PatternModel(resource, patternsPath, patternId, jsonDataFileName, templateName, this.resourceResolver));
}
}
}
return templatesPatterns;
}
示例6: combineData
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
private List<List<ImmutablePair<Gene, List<Sequence>>>> combineData(
final Map<Gene, List<List<Sequence>>> data,
final Comparator<Gene> comparator) {
List<List<ImmutablePair<Gene, List<Sequence>>>> source =
data.entrySet().stream().sorted((e1, e2) -> comparator.compare(e1.getKey(), e2.getKey()))
.map(e -> e.getValue().stream().map(s -> new ImmutablePair<>(e.getKey(), s))
.collect(Collectors.toList())).collect(Collectors.toList());
if (CollectionUtils.isEmpty(source)) {
return Collections.emptyList();
}
List<List<ImmutablePair<Gene, List<Sequence>>>> start = new ArrayList<>();
for (ImmutablePair<Gene, List<Sequence>> p : source.remove(0)) {
List<ImmutablePair<Gene, List<Sequence>>> ll = new ArrayList<>();
ll.add(p);
start.add(ll);
}
return recursiveCombine(start, source);
}
示例7: loadVcfFiles
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
@Transactional(propagation = Propagation.REQUIRED)
public List<VcfFile> loadVcfFiles(List<Long> ids) {
if (CollectionUtils.isEmpty(ids)) {
return Collections.emptyList();
}
List<VcfFile> files = vcfFileDao.loadVcfFiles(ids);
if (files.size() != ids.size()) {
List<Long> notFound = new ArrayList<>(ids);
notFound.removeAll(files.stream().map(BaseEntity::getId).collect(Collectors.toList()));
Assert.isTrue(notFound.isEmpty(), MessageHelper.getMessage(MessagesConstants.ERROR_FILE_NOT_FOUND,
notFound.stream()
.map(i -> i.toString())
.collect(Collectors.joining(", "))));
}
return files;
}
示例8: withPort
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
public ComponentBuilder withPort(Port port) {
if(CollectionUtils.isEmpty(this.ports)) {
this.ports = new ArrayList<>();
}
this.ports.add(port);
return this;
}
示例9: assertNotBlank
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
* 断言集合不为空或null,否则抛RuntimeException
*
* @param collection 断言集合
* @param errMsg 异常描述
*/
@SuppressWarnings("rawtypes")
public static void assertNotBlank(Collection collection, String errMsg) {
if (CollectionUtils.isEmpty(collection)) {
throw new RuntimeException(errMsg);
}
}
示例10: swap
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
private static Map< Serializable, List< ParentChildrenRecursion > > swap ( List< ? extends ParentChildrenRecursion > list ) {
if ( CollectionUtils.isEmpty( list ) ) {
return Collections.emptyMap();
}
Map< Serializable, List< ParentChildrenRecursion > > content = new HashMap<>();
list.forEach( element -> {
List resources = content.get( element.getParentId() );
if ( CollectionUtils.isEmpty( resources ) ) {
resources = new ArrayList<>();
}
resources.add( element );
content.put( element.getParentId() , resources );
} );
return content;
}
示例11: decryptAdapterClientSecrets
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
private Set<AttributeAdapterConnection> decryptAdapterClientSecrets(
final Set<AttributeAdapterConnection> adapters) {
if (CollectionUtils.isEmpty(adapters)) {
return Collections.emptySet();
}
adapters.forEach(adapter -> adapter.setUaaClientSecret(this.encryptor.decrypt(adapter.getUaaClientSecret())));
return adapters;
}
示例12: getPortByMacAddress
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
private Port getPortByMacAddress(String region, String macAddress) {
getOs().useRegion(region);
List<? extends Port> portList = getOs().networking().port().list(PortListOptions.create().macAddress(macAddress));
if (CollectionUtils.isEmpty(portList)) {
log.info(String.format("No ports found with mac: %s in region: %s", macAddress, region));
}
return portList.isEmpty() ? null : portList.get(0);
}
示例13: groupVariations
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
/**
* Groups variations from specified {@link List} of {@link VcfFile}s by specified field
* @param files a {@link List} of {@link FeatureFile}, which indexes to search
* @param query a query to search in index
* @param groupBy a field to perform grouping
* @return a {@link List} of {@link Group}s, mapping field value to number of variations, having this value
* @throws IOException if something goes wrong with the file system
*/
public List<Group> groupVariations(List<VcfFile> files, Query query, String groupBy) throws IOException {
List<Group> res = new ArrayList<>();
if (CollectionUtils.isEmpty(files)) {
return Collections.emptyList();
}
SimpleFSDirectory[] indexes = fileManager.getIndexesForFiles(files);
try (MultiReader reader = openMultiReader(indexes)) {
if (reader.numDocs() == 0) {
return Collections.emptyList();
}
IndexSearcher searcher = new IndexSearcher(reader);
AbstractGroupFacetCollector groupedFacetCollector =
TermGroupFacetCollector.createTermGroupFacetCollector(FeatureIndexFields.UID.fieldName,
getGroupByField(files, groupBy), false, null, GROUP_INITIAL_SIZE);
searcher.search(query, groupedFacetCollector); // Computing the grouped facet counts
TermGroupFacetCollector.GroupedFacetResult groupedResult = groupedFacetCollector.mergeSegmentResults(
reader.numDocs(), 1, false);
List<AbstractGroupFacetCollector.FacetEntry> facetEntries = groupedResult.getFacetEntries(0,
reader.numDocs());
for (AbstractGroupFacetCollector.FacetEntry facetEntry : facetEntries) {
res.add(new Group(facetEntry.getValue().utf8ToString(), facetEntry.getCount()));
}
} finally {
for (SimpleFSDirectory index : indexes) {
IOUtils.closeQuietly(index);
}
}
return res;
}
示例14: withFile
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
public ComponentBuilder withFile(UploadFile file) {
if(CollectionUtils.isEmpty(this.files)) {
this.files = new ArrayList<>();
}
this.files.add(file);
return this;
}
示例15: getAllFiles
import org.apache.commons.collections4.CollectionUtils; //导入方法依赖的package包/类
public List<UploadFile> getAllFiles(){
List<UploadFile> files = new ArrayList<>();
if(!CollectionUtils.isEmpty(this.getComponents())){
files = this.getComponents().stream()
.map(component -> component.getFiles())
.flatMap(list -> list.stream()).collect(Collectors.toList());
}
//add image ports
if(!CollectionUtils.isEmpty(this.getPorts())){
files.addAll(this.getFiles());
}
return files;
}