本文整理汇总了Java中com.google.common.collect.Iterators.toArray方法的典型用法代码示例。如果您正苦于以下问题:Java Iterators.toArray方法的具体用法?Java Iterators.toArray怎么用?Java Iterators.toArray使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.collect.Iterators
的用法示例。
在下文中一共展示了Iterators.toArray方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: lookupNames
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
{
public boolean apply(String p_apply_1_)
{
return !StringUtils.isNullOrEmpty(p_apply_1_);
}
}), String.class);
if (server.isServerInOnlineMode())
{
server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
}
else
{
for (String s : astring)
{
UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
GameProfile gameprofile = new GameProfile(uuid, s);
callback.onProfileLookupSucceeded(gameprofile);
}
}
}
示例2: lookupNames
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
private static void lookupNames(MinecraftServer server, Collection<String> names, ProfileLookupCallback callback)
{
String[] astring = (String[])Iterators.toArray(Iterators.filter(names.iterator(), new Predicate<String>()
{
public boolean apply(@Nullable String p_apply_1_)
{
return !StringUtils.isNullOrEmpty(p_apply_1_);
}
}), String.class);
if (server.isServerInOnlineMode())
{
server.getGameProfileRepository().findProfilesByNames(astring, Agent.MINECRAFT, callback);
}
else
{
for (String s : astring)
{
UUID uuid = EntityPlayer.getUUID(new GameProfile((UUID)null, s));
GameProfile gameprofile = new GameProfile(uuid, s);
callback.onProfileLookupSucceeded(gameprofile);
}
}
}
示例3: getListInstalledPlugins
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
public Path[] getListInstalledPlugins() throws IOException {
if (!Files.exists(environment.pluginsFile())) {
return new Path[0];
}
try (DirectoryStream<Path> stream = Files.newDirectoryStream(environment.pluginsFile())) {
return Iterators.toArray(stream.iterator(), Path.class);
}
}
示例4: createNodes
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
@Override
protected Node[] createNodes(Node key) {
return Iterators.toArray(
Iterators.transform(
Iterators.forArray(super.createNodes(key)),
new Function<Node, Node>() {
@Override
public Node apply(Node input) {
return new NotRootResourceFilterNode(input, project);
}
}),
Node.class);
}
示例5: files
import com.google.common.collect.Iterators; //导入方法依赖的package包/类
/**
* Returns an array of all files in the given directory matching.
*/
public static Path[] files(Path from, DirectoryStream.Filter<Path> filter) throws IOException {
try (DirectoryStream<Path> stream = Files.newDirectoryStream(from, filter)) {
return Iterators.toArray(stream.iterator(), Path.class);
}
}