當前位置: 首頁>>代碼示例>>Java>>正文


Java Validate.notNull方法代碼示例

本文整理匯總了Java中org.apache.commons.lang.Validate.notNull方法的典型用法代碼示例。如果您正苦於以下問題:Java Validate.notNull方法的具體用法?Java Validate.notNull怎麽用?Java Validate.notNull使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.apache.commons.lang.Validate的用法示例。


在下文中一共展示了Validate.notNull方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: tabComplete

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
@Override
public List<String> tabComplete(CommandSender sender,String alias,String[] args){
    Validate.notNull(sender,"Sender cannot be null");
    Validate.notNull(args,"Arguments cannot be null");
    Validate.notNull(alias,"Alias cannot be null");

    if(args.length==1){
        return StringUtil.copyPartialMatches(args[0],COMMANDS,new ArrayList<String>(COMMANDS.size()));
    }
    if(((args.length==2)&&"get".equalsIgnoreCase(args[0]))||"set".equalsIgnoreCase(args[0])){
        MinecraftServer.getServer();
        MinecraftServer.getServer();
        return StringUtil.copyPartialMatches(args[1],MinecraftServer.entityConfig.getSettings().keySet(),new ArrayList<String>(MinecraftServer.tileEntityConfig.getSettings().size()));
    }

    return ImmutableList.of();
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:18,代碼來源:EntityCommand.java

示例2: setDisplayName

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
public void setDisplayName(String displayName) throws IllegalStateException, IllegalArgumentException {
    Validate.notNull(displayName, "Display name cannot be null");
    Validate.isTrue(displayName.length() <= 32, "Display name '" + displayName + "' is longer than the limit of 32 characters");
    CraftScoreboard scoreboard = checkState();

    objective.setDisplayName(displayName);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:8,代碼來源:CraftObjective.java

示例3: addDefaults

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
public void addDefaults( Map<String, Object> defaults )
{
	Validate.notNull( defaults, "Defaults may not be null" );

	for ( Map.Entry<String, Object> entry : defaults.entrySet() ) {
		addDefault( entry.getKey(), entry.getValue() );
	}
}
 
開發者ID:ZP4RKER,項目名稱:zlevels,代碼行數:9,代碼來源:MemoryConfiguration.java

示例4: getEnchantmentLevel

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
@Override
public int getEnchantmentLevel(Enchantment ench) {
    Validate.notNull(ench, "Cannot find null enchantment");
    if (handle == null) {
        return 0;
    }
    return net.minecraft.enchantment.EnchantmentHelper.getEnchantmentLevel(ench.getId(), handle);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:9,代碼來源:CraftItemStack.java

示例5: initialize

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
private synchronized void initialize(Addon addon) {
    Validate.notNull(addon, "Initializing addon cannot be null");
    Validate.isTrue(addon.getClass().getClassLoader() == this, "Cannot initialize plugin outside of this class loader");
    if (this.addon.getDescription() != null) {
        throw new IllegalArgumentException("Addon already initialized!");
    } else {
        addon.init(this, this.dataFolder, this.description);
    }
}
 
開發者ID:AlphaHelixDev,項目名稱:AlphaLibary,代碼行數:10,代碼來源:AddonClassLoader.java

示例6: MemorySection

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
 * Creates an empty MemorySection with the specified parent and path.
 *
 * @param parent Parent section that contains this own section.
 * @param path   Path that you may access this section from via the root
 *               {@link Configuration}.
 * @throws IllegalArgumentException Thrown is parent or path is null, or
 *                                  if parent contains no root Configuration.
 */
protected MemorySection( ConfigurationSection parent, String path )
{
	Validate.notNull( parent, "Parent cannot be null" );
	Validate.notNull( path, "Path cannot be null" );

	this.path = path;
	this.parent = parent;
	this.root = parent.getRoot();

	Validate.notNull( root, "Path cannot be orphaned" );

	this.fullPath = createPath( parent, path );
}
 
開發者ID:ZP4RKER,項目名稱:zlevels,代碼行數:23,代碼來源:MemorySection.java

示例7: DragonTemplate

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
 * Construct a new DragonTemplate object
 * 
 * @param file the file holding this template data
 * @param name the name of the dragon. Can be null
 * @param barStyle the style of the bar. Can be null
 * @param barColour the colour of the bar. Can be null
 */
public DragonTemplate(File file, String name, BarStyle barStyle, BarColor barColour) {
	Validate.notNull(file, "File cannot be null. See DragonTemplate(String, String, BarStyle, BarColor) for null files");
	
	this.file = file;
	this.configFile = YamlConfiguration.loadConfiguration(file);
	this.identifier = file.getName().substring(0, file.getName().lastIndexOf('.'));
	
	this.name = (name != null ? ChatColor.translateAlternateColorCodes('&', name) : null);
	this.barStyle = (barStyle != null ? barStyle : BarStyle.SOLID);
	this.barColour = (barColour != null ? barColour : BarColor.PINK);
	this.loot = new DragonLoot(this);
}
 
開發者ID:2008Choco,項目名稱:DragonEggDrop,代碼行數:21,代碼來源:DragonTemplate.java

示例8: removeAttribute

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
 * Remove an attribute from this template and set its value back to default
 * 
 * @param attribute the attribute to remove
 * @param updateFile whether to update the dragon file or not
 */
public void removeAttribute(Attribute attribute, boolean updateFile) {
	Validate.notNull(attribute, "Cannot remove a null attribute");
	
	this.attributes.remove(attribute);
	
	if (updateFile) {
		this.updateConfig("attributes." + attribute.name(), null);
	}
}
 
開發者ID:2008Choco,項目名稱:DragonEggDrop,代碼行數:16,代碼來源:DragonTemplate.java

示例9: tabComplete

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
@Override
public java.util.List<String> tabComplete(CommandSender sender, String alias, String[] args) throws CommandException, IllegalArgumentException {
	Validate.notNull(sender, "Sender cannot be null");
	Validate.notNull(args, "Arguments cannot be null");
	Validate.notNull(alias, "Alias cannot be null");

	List<String> completions = null;
	try {
		if (completer != null) {
			completions = completer.onTabComplete(sender, this, alias, args);
		}
		if (completions == null && executor instanceof TabCompleter) {
			completions = ((TabCompleter) executor).onTabComplete(sender, this, alias, args);
		}
	} catch (Throwable ex) {
		StringBuilder message = new StringBuilder();
		message.append("Unhandled exception during tab completion for command '/").append(alias).append(' ');
		for (String arg : args) {
			message.append(arg).append(' ');
		}
		message.deleteCharAt(message.length() - 1).append("' in plugin ")
				.append(owningPlugin.getDescription().getFullName());
		throw new CommandException(message.toString(), ex);
	}

	if (completions == null) {
		return super.tabComplete(sender, alias, args);
	}
	return completions;
}
 
開發者ID:HuliPvP,項目名稱:Chambers,代碼行數:31,代碼來源:BukkitCommand.java

示例10: addEntry

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
@Override
public void addEntry(String player) throws IllegalStateException,IllegalArgumentException{
    Validate.notNull(player, "PlayerName cannot be null");
    CraftScoreboard scoreboard = checkState();

    scoreboard.board.func_151392_a(player, team.getRegisteredName());
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:8,代碼來源:CraftTeam.java

示例11: CocoaEffectsModule

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
 * Constructor
 *
 * @param plugin Parent plugin
 * @param api API instance
 * @param moduleConfiguration Module configuration
 */
public CocoaEffectsModule(SurvivalPlugin plugin, SurvivalAPI api, Map<String, Object> moduleConfiguration)
{
    super(plugin, api, moduleConfiguration);
    Validate.notNull(moduleConfiguration, "Configuration cannot be null!");

    this.bonusTime = (int) moduleConfiguration.get("bonus-time");
    this.penaltyTime = (int) moduleConfiguration.get("penalty-time");

    this.cocoa = new ItemStack(Material.INK_SACK, 5, (short) 3);
    ItemMeta meta = this.cocoa.getItemMeta();
    meta.setLore(Arrays.asList(ChatColor.GRAY + "Chaque utilisation vous donne " + this.bonusTime + " secondes", ChatColor.GRAY + " de force et vitesse améliorées", ChatColor.GRAY + " mais les effets contraires par la suite", ChatColor.GRAY + " pendant " + this.penaltyTime + " secondes."));
    meta.setDisplayName(ChatColor.AQUA + "Coco");
    this.cocoa.setItemMeta(meta);
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:22,代碼來源:CocoaEffectsModule.java

示例12: ConstantPotionModule

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
/**
 * Constructor
 *
 * @param plugin Parent plugin
 * @param api API instance
 * @param moduleConfiguration Module configuration
 */
public ConstantPotionModule(SurvivalPlugin plugin, SurvivalAPI api, Map<String, Object> moduleConfiguration)
{
    super(plugin, api, moduleConfiguration);
    Validate.notNull(moduleConfiguration, "Configuration cannot be null!");

    this.potionEffects = (ArrayList<PotionEffect>) this.moduleConfiguration.get("effects");
}
 
開發者ID:SamaGames,項目名稱:SurvivalAPI,代碼行數:15,代碼來源:ConstantPotionModule.java

示例13: Builder

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
public Builder(final VoyageNumber voyageNumber, final Location departureLocation) {
    Validate.notNull(voyageNumber, "Voyage number is required");
    Validate.notNull(departureLocation, "Departure location is required");

    this.voyageNumber = voyageNumber;
    this.departureLocation = departureLocation;
}
 
開發者ID:jboz,項目名稱:living-documentation,代碼行數:8,代碼來源:Voyage.java

示例14: setProfession

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
public void setProfession(Profession profession) {
    Validate.notNull(profession);
    getHandle().setProfession(profession.getId());
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:5,代碼來源:CraftVillager.java

示例15: clearSlot

import org.apache.commons.lang.Validate; //導入方法依賴的package包/類
public void clearSlot(DisplaySlot slot) throws IllegalArgumentException {
    Validate.notNull(slot, "Slot cannot be null");
    board.func_96530_a(CraftScoreboardTranslations.fromBukkitSlot(slot), null);
}
 
開發者ID:UraniumMC,項目名稱:Uranium,代碼行數:5,代碼來源:CraftScoreboard.java


注:本文中的org.apache.commons.lang.Validate.notNull方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。