Example usage for org.apache.commons.lang NullArgumentException NullArgumentException

List of usage examples for org.apache.commons.lang NullArgumentException NullArgumentException

Introduction

In this page you can find the example usage for org.apache.commons.lang NullArgumentException NullArgumentException.

Prototype

public NullArgumentException(String argName) 

Source Link

Document

Instantiates with the given argument name.

Usage

From source file:com.comphenix.xp.extra.ServiceProvider.java

/**
 * Registers a service in the system.// www  .java2 s  .c  o m
 * @param service - the service to register.
 * @return The previously registered service with this name, or NULL otherwise.
 * @throws NullArgumentException If service is null.
 */
public TService register(TService service) {
    if (service == null)
        throw new NullArgumentException("service");

    String name = service.getServiceName();

    // Careful now.
    if (name.equalsIgnoreCase(defaultServiceName))
        throw new IllegalArgumentException("Service cannot have the name DEfAULT. This name is reserved.");

    return setByName(name, service);
}

From source file:fr.gouv.culture.thesaurus.util.template.SortItemWrapper.java

/**
 * Initialise un nouveau wrapper autour d'une chane rgionalise.
 * /*ww w .j  a v a 2s  .  co m*/
 * @param data
 *            Donnes associe  l'lment
 * @param string
 *            Chane rgionalise  wrapper
 * @param collator
 *            Collator  utiliser pour comparer les libells avec la chane
 *            (ne peut tre <code>null</code> si la chane possde une
 *            langue)
 * @param prioritizedLanguages
 *            Languages prioritaires
 */
public SortItemWrapper(final T data, final LocalizedString string, final Collator collator,
        final String[] prioritizedLanguages) {
    super();

    if (string.getLanguage() != null && collator == null) {
        // Si la chane est spcifique  une langue, il faut un moyen de
        // comparer les chanes de la langue.
        throw new NullArgumentException("collator");
    }

    this.prioritizedLanguages = prioritizedLanguages;
    this.data = data;
    this.string = string;
    this.collationData = string.getLanguage() == null ? null
            : new CollationData<LocalizedString>(string.getValue(), null, collator);
}

From source file:it.geosolutions.geoserver.jms.impl.handlers.catalog.CatalogUtils.java

public static <T extends PublishedInfo> List<LayerInfo> localizeLayers(final List<T> info,
        final Catalog catalog) throws IllegalAccessException, InvocationTargetException {
    if (info == null || catalog == null)
        throw new NullArgumentException("Arguments may never be null");
    final List<LayerInfo> localLayerList = new ArrayList<LayerInfo>(info.size());
    final Iterator<LayerInfo> it = localLayerList.iterator();
    while (it.hasNext()) {
        final LayerInfo layer = it.next();
        final LayerInfo localLayer = localizeLayer(layer, catalog);
        if (localLayer != null) {
            localLayerList.add(localLayer);
        } else {//from w ww .  ja v  a2 s . co m
            if (LOGGER.isLoggable(java.util.logging.Level.WARNING)) {
                LOGGER.warning("No such layer called \'" + layer.getName() + "\' can be found: SKIPPING");
            }
        }
    }
    return localLayerList;
}

From source file:com.aionemu.gameserver.model.stats.container.CreatureLifeStats.java

/**
 * This method is called whenever caller wants to absorb creatures's HP
 *
 * @param value/* ww  w .j a v a2 s .c  om*/
 * @param attacker attacking creature or self
 * @return currentHp
 */
public int reduceHp(int value, @Nonnull Creature attacker) {
    if (attacker == null) {
        throw new NullArgumentException("attacker");
    }

    boolean isDied = false;
    hpLock.lock();
    try {
        if (!alreadyDead) {
            int newHp = this.currentHp - value;

            if (newHp < 0) {
                newHp = 0;
                this.currentMp = 0;
                alreadyDead = true;
                isDied = true;
            }
            this.currentHp = newHp;
        }
    } finally {
        hpLock.unlock();
    }
    if (value != 0) {
        onReduceHp();
    }
    if (isDied) {
        getOwner().getController().onDie(attacker);
    }
    return currentHp;
}

From source file:com.comphenix.xp.lookup.ItemQuery.java

/**
 * Creates a query from a given world block.
 * @param block - block to create from.//from w  w  w  .ja  v a  2  s. c om
 * @return The created query.
 */
public static ItemQuery fromExact(Block block) {
    if (block == null)
        throw new NullArgumentException("block");

    return fromExact(block.getTypeId(), (int) block.getData());
}

From source file:com.comphenix.xp.rewards.RewardProvider.java

/**
 * Unregisters a specified reward service.
 * @param rewardType the type of the reward service to unregister.
 * @return The previously registered service with this type, or NULL otherwise.
 *//*ww  w  . ja  v  a2  s. c  om*/
public RewardService unregister(RewardTypes rewardType) {
    if (rewardType == null)
        throw new NullArgumentException("rewardType");
    if (rewardType == RewardTypes.CUSTOM)
        throw new IllegalArgumentException(ERROR_CUSTOM_UNSUPPORTED);
    if (rewardType == RewardTypes.DEFAULT)
        return super.unregister(defaultServiceName);

    RewardService removed = enumLookup.remove(rewardType);

    // Make sure to remove it from the name list too
    if (removed != null)
        super.unregister(removed);
    return removed;
}

From source file:com.eyeq.pivot4j.ui.impl.RenderStrategyImpl.java

/**
 * @param model/*w w  w .  ja  va 2  s  .c  om*/
 * @param renderer
 * @param callback
 * @see com.eyeq.pivot4j.ui.RenderStrategy#render(com.eyeq.pivot4j.PivotModel,
 *      com.eyeq.pivot4j.ui.PivotRenderer,
 *      com.eyeq.pivot4j.ui.PivotLayoutCallback)
 */
public void render(PivotModel model, PivotRenderer renderer, PivotLayoutCallback callback) {
    if (model == null) {
        throw new NullArgumentException("model");
    }

    if (renderer == null) {
        throw new NullArgumentException("renderer");
    }

    CellSet cellSet = model.getCellSet();

    if (cellSet == null) {
        return;
    }

    List<CellSetAxis> axes = cellSet.getAxes();
    if (axes.isEmpty()) {
        return;
    }

    TableHeaderNode columnRoot = createAxisTree(model, renderer, Axis.COLUMNS);
    if (columnRoot == null) {
        return;
    }

    TableHeaderNode rowRoot = createAxisTree(model, renderer, Axis.ROWS);
    if (rowRoot == null) {
        return;
    }

    configureAxisTree(model, renderer, Axis.COLUMNS, columnRoot);
    configureAxisTree(model, renderer, Axis.ROWS, rowRoot);

    invalidateAxisTree(model, Axis.COLUMNS, columnRoot);
    invalidateAxisTree(model, Axis.ROWS, rowRoot);

    RenderContext context = createRenderContext(model, renderer, columnRoot, rowRoot);

    callback.startTable(context);

    renderHeader(context, columnRoot, rowRoot, callback);
    renderBody(context, columnRoot, rowRoot, callback);

    callback.endTable(context);

    if (renderer.getRenderSlicer()) {
        renderFilter(context, callback);
    }
}

From source file:com.eyeq.pivot4j.ui.AbstractPivotRenderer.java

/**
 * @see com.eyeq.pivot4j.ui.PivotRenderer#render(com.eyeq.pivot4j.PivotModel)
 *///from   w  ww. j a  v a 2s . c  o  m
@Override
public void render(PivotModel model) {
    if (model == null) {
        throw new NullArgumentException("model");
    }

    if (renderStrategy == null) {
        throw new IllegalStateException("Renderer was not initialized yet.");
    }

    if (resourceBundle == null) {
        this.resourceBundle = createDefaultResourceBundle(model);
    }

    renderStrategy.render(model, this, this);
}

From source file:com.eyeq.pivot4j.query.QueryAdapter.java

/**
 * @param model/*from   w  w w  .j av a  2s  .  c o  m*/
 */
public QueryAdapter(PivotModel model) {
    if (model == null) {
        throw new NullArgumentException("model");
    }

    this.model = model;
}

From source file:m.c.m.proxyma.context.ProxyFolderBean.java

/**
 * Standard setter method for folderName.<br/>
 * Setting the folder name will set also the URLEncoded version of it.<br/>
 * Note: The foldername can't contain "/" characters.
 *
 * @param folderName the folder name to set
 * @throws NullArgumentException if some parameter is null
 * @throws IllegalArgumentException if the folder name is not valid
 * @throws UnsupportedEncodingException if the default encoding charset specified on the configuration is not supported.
 *//* w  w  w.  j  a  v  a 2s  . co m*/
public synchronized void setFolderName(String newFolderName)
        throws NullArgumentException, IllegalArgumentException, UnsupportedEncodingException {
    if (newFolderName == null) {
        log.warning("Null folderName passed.");
        throw new NullArgumentException("Null folderName passed.");
    } else {
        this.folderName = newFolderName.trim();
        if (this.folderName.length() == 0) {
            log.warning("The passed folderName is an empty (or blank)");
            throw new IllegalArgumentException("The passed folderName is an empty (or blank)");
        } else {
            //encoding-decoding the folder name
            if (this.folderName.indexOf("/") != -1) {
                log.warning("The foldername can't contain a \"/\" character");
                throw new IllegalArgumentException("The foldername can't contain a \"/\" character");
            } else {
                //register the new urlEncoded name for the context (if the folder has a context)
                String oldURLEncodedName = this.URLEncodedName;
                this.URLEncodedName = URLEncoder.encode(this.folderName, defaultEncoding);
                if (context != null)
                    context.updateFolderURLEncodedIndex(oldURLEncodedName, this);
            }
        }
    }
}