当前位置: 首页>>代码示例>>Java>>正文


Java List.isEmpty方法代码示例

本文整理汇总了Java中java.util.List.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java List.isEmpty方法的具体用法?Java List.isEmpty怎么用?Java List.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.List的用法示例。


在下文中一共展示了List.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: printDevice

import java.util.List; //导入方法依赖的package包/类
private void printDevice(DeviceService deviceService,
                         DriverService driverService,
                         Device device) {
    super.printDevice(deviceService, device);
    if (!device.is(InterfaceConfig.class)) {
        // The relevant behavior is not supported by the device.
        print(ERROR_RESULT);
        return;
    }
    DriverHandler h = driverService.createHandler(device.id());
    InterfaceConfig interfaceConfig = h.behaviour(InterfaceConfig.class);

    List<DeviceInterfaceDescription> interfaces =
            interfaceConfig.getInterfaces(device.id());
    if (interfaces == null) {
        print(ERROR_RESULT);
    } else if (interfaces.isEmpty()) {
        print(NO_INTERFACES);
    } else {
        interfaces.forEach(this::printInterface);
    }
}
 
开发者ID:shlee89,项目名称:athena,代码行数:23,代码来源:DeviceInterfacesListCommand.java

示例2: createSubMetrics

import java.util.List; //导入方法依赖的package包/类
protected final <N extends Metrics> N createSubMetrics(
        Function<M, ? extends N> supplier,
        Function<List<? extends N>, ? extends N> dispatchingMetricsSupplier) {
    List<N> allSubMetrics = new ArrayList<>(delegates.size());
    for (M delegate : delegates) {
        N subMetrics = supplier.apply(delegate);
        if (subMetrics != null) {
            allSubMetrics.add(subMetrics);
        }
    }
    if (allSubMetrics.isEmpty()) {
        return null;
    } else if (allSubMetrics.size() == 1) {
        return allSubMetrics.get(0);
    } else {
        return dispatchingMetricsSupplier.apply(allSubMetrics);
    }
}
 
开发者ID:unbroken-dome,项目名称:vertx-spring,代码行数:19,代码来源:AbstractDispatchingMetrics.java

示例3: parseSequence

import java.util.List; //导入方法依赖的package包/类
private Matcher parseSequence() {
    List<Matcher> matchers = new ArrayList<>();
    int index = 0;
    Token token = nextNonSpaceToken();
    Matcher matcher;
    while ((matcher = parseSimpleSelector(token, index++, false)) != null) {
        matchers.add(matcher);
        token = peekToken();
        if (token.isEndOfSequence()) {
            break;
        } else {
            token = nextToken();
        }
    }
    if (matchers.isEmpty()) {
        return null;
    }
    if (!matchers.get(0).getType().representsType()) {
        matchers.add(0, newUniversalSelector());
    }
    return Matchers.allOf(matchers);
}
 
开发者ID:i49,项目名称:cascade,代码行数:23,代码来源:SelectorParser.java

示例4: updateStatusOffline

import java.util.List; //导入方法依赖的package包/类
@Override
public int updateStatusOffline(List<Client> clientList) throws Exception {
    List<Integer> idList = getIdList(clientList);
    if(idList != null && !idList.isEmpty()){
        return scanClientDao.updateStatusOffline(idList, InstanceStatus.offline.value().intValue());
    }
    return 0;
}
 
开发者ID:tiglabs,项目名称:jsf-core,代码行数:9,代码来源:ScanClientManagerImpl.java

示例5: getPreferredProvider

import java.util.List; //导入方法依赖的package包/类
@Nullable
private ComponentName getPreferredProvider(@NonNull List<ComponentName> providers) {
    // In the future, the user will be able to explicitly set their preferred provider in
    // their device settings. For now, we heuristically determine the preferred provider based
    // on the following rules:

    // 1. If there are any unknown providers on the device, there is no preferred provider.
    List<ComponentName> knownProviders = filterToKnownProviders(providers);
    if (knownProviders.size() != providers.size()) {
        return null;
    }

    // 2. If there are no known providers, then there is no preferred provider. Unknown
    // providers are not trusted for automatic usage.
    if (knownProviders.isEmpty()) {
        return null;
    }

    // 3. If there is exactly one provider on the device and it is known,
    // it is the preferred provider.
    if (knownProviders.size() == 1) {
        return knownProviders.get(0);
    }

    // 3. If there are exactly two known providers on the device, and one of them is Google,
    // choose the other one.
    // This reflects the reality that Google is pre-installed on most devices, whereas a second
    // provider would likely have been explicitly installed by the user - it is likely that
    // their intent is to use this other provider.
    providers = filterOutGoogle(knownProviders);
    if (providers.size() == 1) {
        return knownProviders.get(0);
    }

    // 4. Otherwise, there is no preferred provider.
    return null;
}
 
开发者ID:openid,项目名称:OpenYOLO-Android,代码行数:38,代码来源:CredentialClient.java

示例6: listToString

import java.util.List; //导入方法依赖的package包/类
/**
 * 将一个list转为以split分隔的string
 * 
 * @param list
 * @param split
 * @return
 */
public static String listToString(List list, String split) {
	if (list == null || list.isEmpty())
		return "";
	StringBuffer sb = new StringBuffer();
	for (Object obj : list) {
		if (sb.length() != 0) {
			sb.append(split);
		}
		sb.append(obj.toString());
	}
	return sb.toString();
}
 
开发者ID:yulele166,项目名称:pub-service,代码行数:20,代码来源:StringUtil.java

示例7: gotoMarker

import java.util.List; //导入方法依赖的package包/类
/**
 * <!-- begin-user-doc -->
 * <!-- end-user-doc -->
 * @generated
 */
public void gotoMarker(IMarker marker) {
	List<?> targetObjects = markerHelper.getTargetObjects(editingDomain, marker);
	if (!targetObjects.isEmpty()) {
		setSelectionToViewer(targetObjects);
	}
}
 
开发者ID:polarsys,项目名称:time4sys,代码行数:12,代码来源:DesignEditor.java

示例8: displayUnits

import java.util.List; //导入方法依赖的package包/类
/**
 * Debug action to dump a players units/iterators to stderr.
 *
 * Called from the debug menu.
 * TODO: missing i18n
 *
 * @param freeColClient The {@code FreeColClient} for the game.
 */
public static void displayUnits(final FreeColClient freeColClient) {
    final Player player = freeColClient.getMyPlayer();
    List<Unit> all = player.getUnitList();
    LogBuilder lb = new LogBuilder(256);
    lb.add("\nActive units:\n");

    Unit u, first = player.getNextActiveUnit();
    if (first != null) {
        lb.add(first.toString(), "\nat ", first.getLocation(), "\n");
        all.remove(first);
        while (player.hasNextActiveUnit()
            && (u = player.getNextActiveUnit()) != first) {
            lb.add(u, "\nat ", u.getLocation(), "\n");
            all.remove(u);
        }
    }
    lb.add("Going-to units:\n");
    first = player.getNextGoingToUnit();
    if (first != null) {
        all.remove(first);
        lb.add(first, "\nat ", first.getLocation(), "\n");
        while (player.hasNextGoingToUnit()
            && (u = player.getNextGoingToUnit()) != first) {
            lb.add(u, "\nat ", u.getLocation(), "\n");
            all.remove(u);
        }
    }
    lb.add("Remaining units:\n");
    while (!all.isEmpty()) {
        u = all.remove(0);
        lb.add(u, "\nat ", u.getLocation(), "\n");
    }

    freeColClient.getGUI().showInformationMessage(lb.toString());
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:44,代码来源:DebugUtils.java

示例9: csBuildBuilding

import java.util.List; //导入方法依赖的package包/类
/**
 * Builds a building from a build queue.
 *
 * @param buildQueue The {@code BuildQueue} to build from.
 * @param cs A {@code ChangeSet} to update.
 * @return True if the build succeeded.
 */
private boolean csBuildBuilding(BuildQueue<? extends BuildableType> buildQueue,
                                ChangeSet cs) {
    BuildingType type = (BuildingType) buildQueue.getCurrentlyBuilding();
    Tile copied = getTile().getTileToCache();
    BuildingType from = type.getUpgradesFrom();
    boolean success;
    if (from == null) {
        success = buildBuilding(new ServerBuilding(getGame(), this, type));//-til
    } else {
        Building building = getBuilding(from);
        List<Unit> eject = building.upgrade();//-til
        success = eject != null;
        if (success) {
            ejectUnits(building, eject);//-til
            if (!eject.isEmpty()) getTile().cacheUnseen(copied);//+til
        } else {
            cs.addMessage(owner, getUnbuildableMessage(type));
        }
    }
    if (success) {
        cs.addMessage(owner,
            new ModelMessage(MessageType.BUILDING_COMPLETED,
                             "model.colony.buildingReady", this)
                .addName("%colony%", getName())
                .addNamed("%building%", type));
        if (owner.isAI()) {
            firePropertyChange(REARRANGE_COLONY, true, false);
        }
        logger.info("New building in " + getName()
            + ": " + type.getSuffix());
    }
    return success;
}
 
开发者ID:wintertime,项目名称:FreeCol,代码行数:41,代码来源:ServerColony.java

示例10: composite

import java.util.List; //导入方法依赖的package包/类
/**
 * Creates a composite iterator.
 *
 * @param items      the list items from which iterators can be retrieved.
 * @param toIterator the function to retrieve an iterator from a list item.
 * @param <T>        the type of the list items.
 * @param <S>        the iterated type.
 * @return a composite iterator.
 */
public static <T, S> Iterator<S> composite(
        final List<T> items,
        final Function<T, Iterator<S>> toIterator
) {
    final MutableContainer<Iterator<S>> container = new MutableContainer<>();
    return new Iterator<S>() {
        @Override
        public boolean hasNext() {
            if (container.getObject() == null || !container.getObject().hasNext()) {
                if (items.isEmpty()) {
                    return false;
                }
                container.setObject(toIterator.apply(items.remove(0)));
            } else {
                return true;
            }
            return hasNext();
        }

        @Override
        public S next() {
            if (!hasNext()) {
                return null;
            }
            return container.getObject().next();
        }
    };
}
 
开发者ID:dajudge,项目名称:testee.fi,代码行数:38,代码来源:IteratorUtils.java

示例11: run

import java.util.List; //导入方法依赖的package包/类
public Optional<String> run() throws IOException {
    Stopwatch stopwatch = Stopwatch.createStarted();
    log.info("Start generating {}", outputZone);
    new File(outputZone).mkdirs();

    List<String> profileShapeFiles = newArrayList();

    for (ClassInfo clazz : shapefiles()) {
        log.info("Converting {}", clazz.getSimpleName());
        TomtomShapefile shapefile = (TomtomShapefile) injector.getInstance(clazz.load());
        if (shapefile.getFile().exists()) {
            shapefile.serialize(outputZone);
            profileShapeFiles.add(shapefile.getOutputFile());
        } else {
            log.info("No input file found");
        }
    }

    if (profileShapeFiles.isEmpty()) {
        return empty();
    }

    osmMerger.merge(profileShapeFiles, outputZone + OSM_SUFFIX);
    log.info("Done generating {} in {}", outputZone + OSM_SUFFIX, stopwatch);

    stopwatch.reset();
    stopwatch.start();

    splitter.run();
    log.info("Done splitting {} in {}", outputZone, stopwatch);

    return of(outputZone + OSM_SUFFIX);
}
 
开发者ID:Mappy,项目名称:fpm,代码行数:34,代码来源:Tomtom2Osm.java

示例12: call

import java.util.List; //导入方法依赖的package包/类
@Override
public Void call () throws HgException {
    OutputLogger logger = supp.getLogger();
    topPatch = FetchAction.selectPatch(root);
    if (topPatch != null) {
        supp.setDisplayName(Bundle.MSG_PullAction_popingPatches());
        SystemAction.get(QGoToPatchAction.class).popAllPatches(root, logger);
        supp.setDisplayName(Bundle.MSG_PullAction_pulling());
        logger.output(""); // NOI18N
    }
    if (supp.isCanceled()) {
        return null;
    }
    List<String> list;
    if(type == PullType.LOCAL){
        supp.setDisplayName(Bundle.MSG_PullAction_progress_pullingFromLocal());
        list = HgCommand.doPull(root, revision, branch, logger);
    }else{
        supp.setDisplayName(Bundle.MSG_PullAction_progress_unbundling());
        list = HgCommand.doUnbundle(root, fileToUnbundle, false, logger);
    }
    if (list != null && !list.isEmpty()) {
        annotateChangeSets(HgUtils.replaceHttpPassword(listIncoming), PullAction.class, "MSG_CHANGESETS_TO_PULL", logger); // NOI18N
        handlePulledChangesets(list);
    }

    return null;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:29,代码来源:PullAction.java

示例13: getConfig

import java.util.List; //导入方法依赖的package包/类
/**
 * Helper method to get configuration for S3 implementation of {@link FileSystem} from
 * given S3 access credentials and property list.
 */
private static Map<String, String> getConfig(final String accessKey, final String accessSecret,
    final boolean secure, List<String> externalBuckets, final Map<String, String> properties) {
  final Map<String, String> finalProperties = Maps.newHashMap();
  finalProperties.put(FileSystem.FS_DEFAULT_NAME_KEY, "dremioS3:///");
  finalProperties.put("fs.dremioS3.impl", S3FileSystem.class.getName());
  finalProperties.put(MAXIMUM_CONNECTIONS, String.valueOf(DEFAULT_MAX_CONNECTIONS));
  if(accessKey != null){
    finalProperties.put(ACCESS_KEY, accessKey);
    finalProperties.put(SECRET_KEY, accessSecret);
  } else {
    // don't use Constants here as it breaks when using older MapR/AWS files.
    finalProperties.put("fs.s3a.aws.credentials.provider", "org.apache.hadoop.fs.s3a.AnonymousAWSCredentialsProvider");
  }

  if (properties != null && !properties.isEmpty()) {
    for (Entry<String, String> property : properties.entrySet()) {
      finalProperties.put(property.getKey(), property.getValue());
    }
  }


  finalProperties.put(SECURE_CONNECTIONS, String.valueOf(secure));
  if(externalBuckets != null && !externalBuckets.isEmpty()){
    finalProperties.put(EXTERNAL_BUCKETS, Joiner.on(",").join(externalBuckets));
  }else {
    if(accessKey == null){
      throw UserException.validationError()
        .message("Failure creating S3 connection. You must provide at least one of: (1) access key and secret key or (2) one or more external buckets.")
        .build(logger);
    }
  }

  return finalProperties;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:39,代码来源:S3PluginConfig.java

示例14: getActions

import java.util.List; //导入方法依赖的package包/类
/**
 * merge action for the topcomponent and the enclosed MultiViewElement..
 * 
 */
@Override
public Action[] getActions() {
    //TEMP don't delegate to element's actions..
    Action[] superActions = superActions4Tests == null ? super.getActions() : superActions4Tests;
    List<Action> acts = new ArrayList<Action>(Arrays.asList(peer.peerGetActions(superActions)));
    if( !acts.isEmpty() )
        acts.add(null);
    acts.add(new EditorsAction());
    if( canSplit() ) {
        acts.add(new SplitAction(true));
    }
    return acts.toArray(new Action[acts.size()]);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:18,代码来源:MultiViewTopComponent.java

示例15: collectAndRegisterProjects

import java.util.List; //导入方法依赖的package包/类
/**
 * Collects the projects to compile and finds their dependencies in the given search paths and registers them with
 * the file-based workspace.
 *
 * @param searchPaths
 *            where to search for dependent projects.
 * @param projectPaths
 *            the projects to compile. the base folder of each project must be provided.
 * @param singleSourceFiles
 *            if non-empty limit compilation to the sources files listed here
 * @return an instance of {@link BuildSet} containing the collected projects and a filter to apply if single source
 *         files were requested to be compiled
 * @throws N4JSCompileException
 *             if an error occurs while registering the projects
 */
private BuildSet collectAndRegisterProjects(List<File> searchPaths, List<File> projectPaths,
		List<File> singleSourceFiles) throws N4JSCompileException {

	// Make absolute, since downstream URI conversion doesn't work if relative dir only.
	List<File> absSearchPaths = HeadlessHelper.toAbsoluteFileList(searchPaths);
	List<File> absProjectPaths = HeadlessHelper.toAbsoluteFileList(projectPaths);
	List<File> absSingleSourceFiles = HeadlessHelper.toAbsoluteFileList(singleSourceFiles);

	// Discover projects in search paths.
	List<File> discoveredProjectLocations = HeadlessHelper.collectAllProjectPaths(absSearchPaths);

	// Discover projects for single source files.
	List<File> singleSourceProjectLocations = findProjectsForSingleFiles(absSingleSourceFiles);

	// Register single-source projects as to be compiled as well.
	List<File> absRequestedProjectLocations = Collections2.concatUnique(absProjectPaths,
			singleSourceProjectLocations);

	// Convert absolute locations to file URIs.
	List<URI> requestedProjectURIs = createFileURIs(absRequestedProjectLocations);
	List<URI> discoveredProjectURIs = createFileURIs(discoveredProjectLocations);

	// Obtain the projects and store them.
	List<N4JSProject> requestedProjects = getN4JSProjects(requestedProjectURIs);
	List<N4JSProject> discoveredProjects = getN4JSProjects(discoveredProjectURIs);

	// Register all projects with the file based workspace.
	registerProjectsToFileBasedWorkspace(Iterables.concat(requestedProjectURIs, discoveredProjectURIs));

	// Create a filter that applies only to the given single source files if any were requested to be compiled.
	Predicate<URI> resourceFilter;
	if (absSingleSourceFiles.isEmpty()) {
		resourceFilter = u -> true;
	} else {
		Set<URI> singleSourceURIs = new HashSet<>(createFileURIs(absSingleSourceFiles));
		resourceFilter = u -> singleSourceURIs.contains(u);
	}

	return new BuildSet(requestedProjects, discoveredProjects, resourceFilter);
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:56,代码来源:N4HeadlessCompiler.java


注:本文中的java.util.List.isEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。