本文整理汇总了Java中org.spongepowered.api.util.annotation.NonnullByDefault类的典型用法代码示例。如果您正苦于以下问题:Java NonnullByDefault类的具体用法?Java NonnullByDefault怎么用?Java NonnullByDefault使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
NonnullByDefault类属于org.spongepowered.api.util.annotation包,在下文中一共展示了NonnullByDefault类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: parseValue
import org.spongepowered.api.util.annotation.NonnullByDefault; //导入依赖的package包/类
/**
* Attempt to extract a value for this element from the given arguments.
* This method is expected to have no side-effects for the source, meaning
* that executing it will not change the state of the {@link CommandSource}
* in any way.
*
* @param source The source to parse for
* @param args the arguments
* @return The extracted value
* @throws ArgumentParseException if unable to extract a value
*/
@Override
@Nullable
@NonnullByDefault
protected Object parseValue(CommandSource source, CommandArgs args) throws ArgumentParseException {
String type = args.next().toLowerCase();
if (LoadedRegion.ChunkType.asMap().containsKey(type)) {
if (source.hasPermission(String.format("%s.%s", Permissions.COMMAND_CREATE, type)))
return LoadedRegion.ChunkType.asMap().get(type);
else
throw new ArgumentParseException(Text.of(TextColors.RED, String.format("You do not have permission to create %s chunks", type)), type, 0);
} else {
throw new ArgumentParseException(Text.of(TextColors.RED, "Chunk type does not exist."), type, 0);
}
}
开发者ID:DevOnTheRocks,项目名称:StickyChunk,代码行数:27,代码来源:ChunkTypeArgument.java
示例2: complete
import org.spongepowered.api.util.annotation.NonnullByDefault; //导入依赖的package包/类
/**
* Fetch completions for command arguments.
*
* @param src The source requesting tab completions
* @param args The arguments currently provided
* @param context The context to store state in
* @return Any relevant completions
*/
@Override
@NonnullByDefault
public List<String> complete(CommandSource src, CommandArgs args, CommandContext context) {
try {
String type = args.peek().toLowerCase();
return LoadedRegion.ChunkType.asMap().entrySet().stream()
.filter(s -> s.getKey().startsWith(type))
.filter(s -> Permissions.hasPermission(src, s.getKey()))
.map(Map.Entry::getKey)
.collect(Collectors.toList());
} catch (ArgumentParseException e) {
e.printStackTrace();
}
return Lists.newArrayList();
}
开发者ID:DevOnTheRocks,项目名称:StickyChunk,代码行数:25,代码来源:ChunkTypeArgument.java
注:本文中的org.spongepowered.api.util.annotation.NonnullByDefault类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论