List of usage examples for org.apache.commons.lang NullArgumentException NullArgumentException
public NullArgumentException(String argName)
Instantiates with the given argument name.
From source file:com.comphenix.xp.extra.ServiceProvider.java
/** * Called by the register function to associate a service with a name. * @param name - name of the service to register. * @param service - service to register. * @throws NullArgumentException Service name cannot be null. *//* w w w . java 2s. c om*/ protected TService setByName(String name, TService service) { if (name == null) throw new NullArgumentException("Service name cannot be null."); else return nameLookup.put(name, service); }
From source file:com.comphenix.xp.parser.text.MobMatcher.java
/** * Registers a category with the given name. * @param categoryName - name of the category. * @param types - list of mob ids in that category. */// ww w .j av a 2 s.com public void registerCategory(String categoryName, Short... types) { if (categoryName == null) throw new NullArgumentException("categoryName"); if (types == null) throw new NullArgumentException("types"); categories.put(categoryName, Lists.newArrayList(types)); }
From source file:m.c.m.proxyma.context.ProxyFolderBean.java
/** * Standard setter method for destinationAsString * @param destinationAsString the remote destinationAsString for this folder * @throws NullArgumentException if some parameter is null * @throws IllegalArgumentException if the destinationAsString parameter is a malformed URL *///from w w w .ja va 2s . c o m public synchronized void setDestination(String destination) { if (destination == null) { log.warning("Null destination passed."); throw new NullArgumentException("Null destination passed."); } else { destination = destination.trim(); if (destination.length() == 0) { log.warning("The passed destination is an empty (or blank) string"); throw new IllegalArgumentException("The passed folderName is an empty (or blank) string"); } else { //Check if it's a valid URL try { //remove tailing "/" if any if (destination.endsWith("/")) this.destinationAsString = destination.substring(0, destination.length() - 1); else this.destinationAsString = destination; //register the new urlEncoded name for the context (if the folder has a context) URL oldDestination = this.destinationAsURL; destinationAsURL = new URL(this.destinationAsString); if (context != null) context.updateFolderDestinationIndex(oldDestination, this); } catch (MalformedURLException ex) { log.warning("Destination \"" + destination + "\" is an Invalid URL."); throw new IllegalArgumentException("Destination \"" + destination + "\" is an Invalid URL."); } } } }
From source file:com.sindicetech.siren.solr.facet.SirenFieldFacetExtractor.java
/** * The entry point of the generateFacetsForLeaves() methods. * * DFS through the sirenNode JsonNode. Generates a {@link SirenFacetEntry} for each * leaf.//from w w w . j av a 2 s . c o m * * @param sirenNode The Json to walk through. * @param fieldName The name of the ExtendedJsonField of the original SolrDocument the value of which is sirenNode. * @param path The path currently visited by the DFS algorithms. Should be an empty String "" in the initial call. * @param facets The entries generated for the leaves. Should be an not null list. * * @throws NullArgumentException if path or facets are null. */ protected void generateFacetsForLeaves(JsonNode sirenNode, String fieldName, ExtendedJsonField field, String path, List<SirenFacetEntry> facets) { if (facets == null) { throw new NullArgumentException("Parameter facets must not be null"); } if (path == null) { throw new NullArgumentException("Parameter path must not be null"); } if (sirenNode.isValueNode()) { generateFacetsForLeaves((ValueNode) sirenNode, fieldName, field, path, facets); } if (sirenNode.isArray()) { generateFacetsForLeaves((ArrayNode) sirenNode, fieldName, field, path, facets); } if (sirenNode.isObject()) { generateFacetsForLeaves((ObjectNode) sirenNode, fieldName, field, path, facets); } }
From source file:com.eyeq.pivot4j.query.Quax.java
/** * @param ordinal//from w w w . j a va 2s. c o m * @param model */ public Quax(int ordinal, PivotModel model) { if (model == null) { throw new NullArgumentException("model"); } this.ordinal = ordinal; this.model = model; this.quaxUtil = new QuaxUtil(getModel().getCube()); }
From source file:com.comphenix.xp.rewards.xp.RewardEconomy.java
@Override public void reward(World world, Location point, ResourceHolder resource) { if (world == null) throw new NullArgumentException("world"); if (point == null) throw new NullArgumentException("point"); if (!(resource instanceof CurrencyHolder)) throw new IllegalArgumentException("Can only award currency."); ItemStack stack = economyItem != null ? economyItem : defaultItem; Integer worth = economyWorth != null ? economyWorth : defaultWorth; // Support negative rewards int amount = Math.abs(resource.getAmount()); int sign = resource.getAmount() < 0 ? -1 : 1; // Make sure it's valid too if (worth < 1) { worth = defaultWorth;//w ww .ja v a 2 s. c o m } stack.addUnsafeEnchantment(Enchantment.ARROW_DAMAGE, -1); // Create the proper amount of items for (; amount > 0; amount -= worth) { int thisAmount = sign * Math.min(amount, worth); ItemStack thisStack = stack.clone(); ItemMeta meta = thisStack.getItemMeta(); meta.setDisplayName(Integer.toString(thisAmount)); thisStack.setItemMeta(meta); Item spawned = world.dropItemNaturally(point, thisStack); listener.pinReward(spawned, thisAmount); } }
From source file:m.c.m.proxyma.resource.ProxymaResource.java
/** * Add a new Attribute to the resource.//from www.ja v a 2s .com * Note: any duplicated entry will be overwritten. Use the containsAttribute() method to check if you care about to not overwrite anything. * * @param attributeName the name of the attribute to add. * @param attributeValue the value of the attribute, it can be any kind of object so it's a responsability of the reader to do the upper-cast to the proper class. * @throws NullArgumentException if the attribute name is null */ public void addAttibute(String attributeName, Object attributeValue) throws NullArgumentException { if (attributeName == null || attributeValue == null) { log.warning("Null attribute name or value parameter.. Ignoring operation"); throw new NullArgumentException("Null attribute name parameter.. Ignoring operation"); } else { boolean exists = attributes.containsKey(attributeName); if (exists) { log.finer("The attribute \"" + attributeName + "\" already exists.. overwriting it."); attributes.remove(attributeName); } else { log.finer("Adding new attribute " + attributeName); } attributes.put(attributeName, attributeValue); } }
From source file:com.eyeq.pivot4j.ui.property.PropertySupport.java
/** * @see com.eyeq.pivot4j.state.Bookmarkable#restoreState(java.io.Serializable) *//*from w ww . j ava2s . c om*/ @Override public void restoreState(Serializable state) { if (state == null) { throw new NullArgumentException("state"); } Serializable[] states = (Serializable[]) state; this.properties.clear(); for (Serializable st : states) { Serializable[] pair = (Serializable[]) st; boolean conditional = (Boolean) pair[0]; Property property; // TODO Need more robust method to determine property types. if (conditional) { property = new ConditionalProperty(conditionFactory); } else { property = new SimpleProperty(); } property.restoreState(pair[1]); this.properties.put(property.getName(), property); } }
From source file:com.comphenix.xp.messages.MessageFormatter.java
/** * Adds every parameter in both message formatters. Note that a and b * must be non-null and have the same player source. * @param a - first message formatter to add. * @param b - second message formatter to add. * @return The resulting message formatter. *///from w w w . java2 s . com public static MessageFormatter add(MessageFormatter a, MessageFormatter b) { if (a == null) throw new NullArgumentException("a"); if (b == null) throw new NullArgumentException("b"); // Add the two formatters return a.add(b); }
From source file:com.comphenix.xp.parser.text.MobMatcher.java
/** * Unregisters the given category./* w w w .j a va2 s. co m*/ * @param categoryName - name of the category to unregister. * @return List of mobs from the category that was unregistered, or NULL if no category could be found. */ public List<Short> unregisterCategory(String categoryName) { if (categoryName == null) throw new NullArgumentException("categoryName"); return categories.remove(categoryName); }