Example usage for org.apache.commons.math3.exception NullArgumentException NullArgumentException

List of usage examples for org.apache.commons.math3.exception NullArgumentException NullArgumentException

Introduction

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

Prototype

public NullArgumentException() 

Source Link

Document

Default constructor.

Usage

From source file:eu.crisis_economics.abm.markets.clearing.heterogeneous.MixedClearingNetwork.java

/**
  * Apply a clearing algorithm to the network. The clearing algorithm
  * will modify the state of edge rates in the network in an attempt
  * to match supply and demand for interacting network parties.
  *//*from ww  w .  j a va2  s  . c  om*/
public double applyClearingAlgorithm(final MixedClearingNetworkAlgorithm clearingAlgorithm) {
    if (clearingAlgorithm == null)
        throw new NullArgumentException();
    final double residualCost = clearingAlgorithm.applyToNetwork(this);
    return residualCost;
}

From source file:eu.crisis_economics.abm.contracts.stocks.UniqueStockExchange.java

@Override
public double getStockPrice(final String stockName) {
    if (stockName == null)
        throw new NullArgumentException();
    assertHasStock(stockName);//from  w  ww  .  ja va  2  s. com
    return stockPrices.get(stockName);
}

From source file:eu.crisis_economics.abm.contracts.loans.RepaymentPlanLoan.java

@Override
public void transferToNewLender(final Lender newLender) {
    if (newLender == null)
        throw new NullArgumentException();
    this.lender.removeAsset(this);
    this.lender = newLender;
    this.lender.addAsset(this);
    this.loanSettlement = SettlementFactory.createDirectSettlement(borrower, lender);
}

From source file:eu.crisis_economics.abm.contracts.stocks.UniqueStockExchange.java

/**
  * Erase a replace an entire stock. This method terminates all existing
  * stock accounts in the stock type issued by the releaser. Stock holders
  * whose accounts are terminated are not compensated for the loss of their
  * share assets. //  w  w  w. j  a  v  a2  s.co m
  * 
  * Arguments to this method cannot be null, and it should be the case that
  * List<Pair<StockHolder, Double>> newShareOwnerships is both (a) non-empty,
  * and (b) composed of non-null, non-negative values; otherwise 
  * IllegalArgumentException is raised and no stock accounts or share 
  * prices are modified. double newPricePerShare cannot be negative or
  * zero.
  */
@Override
public void eraseAndReplaceStockWithoutCompensation(final String uniqueStockName,
        final List<Pair<StockHolder, Double>> stockOwnerships, final double newPricePerShare) {
    if (uniqueStockName == null || stockOwnerships == null)
        throw new NullArgumentException();
    assertHasStock(uniqueStockName);
    if (newPricePerShare <= 0. || stockOwnerships.isEmpty()) {
        /*
         * Price per share cannot be zero in this edition. In the current implementation,
         * share price can drop to zero only if aggregate stockholder investment is zero.
         * In this eventuality, existing stockholders are permitted to retain their
         * existing shares at a small nonzero price. The restorative price per share is 
         * the value ZERO_INVESTMENT_PRICE_PER_SHARE.
         */
        final String warningMsg = "StockExchange: price per share for stock type " + uniqueStockName
                + " has reached" + "the lower bound price " + ZERO_INVESTMENT_PRICE_PER_SHARE + ".";
        System.err.println(warningMsg);
        setStockPrice(uniqueStockName, ZERO_INVESTMENT_PRICE_PER_SHARE);
        return;
    }
    for (final Pair<StockHolder, Double> record : stockOwnerships) {
        if (record.getSecond() < 0.)
            throw new IllegalArgumentException(
                    "StockExchange.eraseAndReplaceStockWithoutCompensation: stockholder (" + record.getFirst()
                            + ") is null or has an invalid share endowment (value " + record.getSecond()
                            + ").");
    }
    final StockOwnershipTracker tracker = stockOwnershipTrackers.get(uniqueStockName);
    tracker.terminateAllExistingShareAccountsWithoutCompensation();
    for (Pair<StockHolder, Double> record : stockOwnerships)
        StockAccount.create(record.getFirst(), tracker.getStockReleaser(), record.getSecond());
    setStockPrice(uniqueStockName, newPricePerShare);
}

From source file:embedded2.ESecure.TTest.java

/**
 * Check sample data./*from   w w w  . ja v a 2  s.  c  o m*/
 *
 * @param data Sample data.
 * @throws NullArgumentException if {@code data} is {@code null}.
 * @throws NumberIsTooSmallException if there is not enough sample data.
 */
private static void checkSampleData(final double[] data)
        throws NullArgumentException, NumberIsTooSmallException {

    if (data == null) {
        throw new NullArgumentException();
    }
    if (data.length < 2) {
        throw new NumberIsTooSmallException(LocalizedFormats.INSUFFICIENT_DATA_FOR_T_STATISTIC, data.length, 2,
                true);
    }

}

From source file:embedded2.ESecure.TTest.java

/**
 * Check sample data.// ww w.j  a v  a2  s.c o m
 *
 * @param stat Statistical summary.
 * @throws NullArgumentException if {@code data} is {@code null}.
 * @throws NumberIsTooSmallException if there is not enough sample data.
 */
private static void checkSampleData(final StatisticalSummary stat)
        throws NullArgumentException, NumberIsTooSmallException {

    if (stat == null) {
        throw new NullArgumentException();
    }
    if (stat.getN() < 2) {
        throw new NumberIsTooSmallException(LocalizedFormats.INSUFFICIENT_DATA_FOR_T_STATISTIC, stat.getN(), 2,
                true);
    }

}

From source file:org.apache.kylin.cube.cuboid.algorithm.generic.lib.ListPopulation.java

/**
 * Creates a new ListPopulation instance.
 * <p>//  w ww .j  ava2  s  .c  om
 * Note: the chromosomes of the specified list are added to the population.
 *
 * @param chromosomes list of chromosomes to be added to the population
 * @param populationLimit maximal size of the population
 * @throws NullArgumentException if the list of chromosomes is {@code null}
 * @throws NotPositiveException if the population limit is not a positive number (&lt; 1)
 * @throws NumberIsTooLargeException if the list of chromosomes exceeds the population limit
 */
public ListPopulation(final List<Chromosome> chromosomes, final int populationLimit)
        throws NullArgumentException, NotPositiveException, NumberIsTooLargeException {

    if (chromosomes == null) {
        throw new NullArgumentException();
    }
    if (populationLimit <= 0) {
        throw new NotPositiveException(LocalizedFormats.POPULATION_LIMIT_NOT_POSITIVE, populationLimit);
    }
    if (chromosomes.size() > populationLimit) {
        throw new NumberIsTooLargeException(LocalizedFormats.LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE,
                chromosomes.size(), populationLimit, false);
    }
    this.populationLimit = populationLimit;
    this.chromosomes = new ArrayList<Chromosome>(populationLimit);
    this.chromosomes.addAll(chromosomes);
}

From source file:org.apache.kylin.cube.cuboid.algorithm.generic.lib.ListPopulation.java

/**
 * Sets the list of chromosomes.//  w ww. jav  a 2 s  . c o m
 * <p>
 * Note: this method removes all existing chromosomes in the population and adds all chromosomes
 * of the specified list to the population.
 *
 * @param chromosomes the list of chromosomes
 * @throws NullArgumentException if the list of chromosomes is {@code null}
 * @throws NumberIsTooLargeException if the list of chromosomes exceeds the population limit
 * @deprecated use {@link #addChromosomes(Collection)} instead
 */
@Deprecated
public void setChromosomes(final List<Chromosome> chromosomes)
        throws NullArgumentException, NumberIsTooLargeException {

    if (chromosomes == null) {
        throw new NullArgumentException();
    }
    if (chromosomes.size() > populationLimit) {
        throw new NumberIsTooLargeException(LocalizedFormats.LIST_OF_CHROMOSOMES_BIGGER_THAN_POPULATION_SIZE,
                chromosomes.size(), populationLimit, false);
    }
    this.chromosomes.clear();
    this.chromosomes.addAll(chromosomes);
}

From source file:org.gitools.analysis.groupcomparison.format.math33Preview.MathArrays.java

/**
 * Sort an array in place and perform the same reordering of entries on
 * other arrays.  This method works the same as the other
 * {@link #sortInPlace(double[], double[][]) sortInPlace} method, but
 * allows the order of the sort to be provided in the {@code dir}
 * parameter.//  w  ww  .j  av  a2  s. co  m
 *
 * @param x     Array to be sorted and used as a pattern for permutation
 *              of the other arrays.
 * @param dir   Order direction.
 * @param yList Set of arrays whose permutations of entries will follow
 *              those performed on {@code x}.
 * @throws DimensionMismatchException if any {@code y} is not the same
 *                                    size as {@code x}.
 * @throws NullArgumentException      if {@code x} or any {@code y} is null
 * @since 3.0
 */
public static void sortInPlace(double[] x, final OrderDirection dir, double[]... yList)
        throws NullArgumentException, DimensionMismatchException {

    // Consistency checks.
    if (x == null) {
        throw new NullArgumentException();
    }

    final int yListLen = yList.length;
    final int len = x.length;

    for (int j = 0; j < yListLen; j++) {
        final double[] y = yList[j];
        if (y == null) {
            throw new NullArgumentException();
        }
        if (y.length != len) {
            throw new DimensionMismatchException(y.length, len);
        }
    }

    // Associate each abscissa "x[i]" with its index "i".
    final List<Pair<Double, Integer>> list = new ArrayList<Pair<Double, Integer>>(len);
    for (int i = 0; i < len; i++) {
        list.add(new Pair<Double, Integer>(x[i], i));
    }

    // Create comparators for increasing and decreasing orders.
    final Comparator<Pair<Double, Integer>> comp = dir == MathArrays.OrderDirection.INCREASING
            ? new Comparator<Pair<Double, Integer>>() {
                public int compare(Pair<Double, Integer> o1, Pair<Double, Integer> o2) {
                    return o1.getKey().compareTo(o2.getKey());
                }
            }
            : new Comparator<Pair<Double, Integer>>() {
                public int compare(Pair<Double, Integer> o1, Pair<Double, Integer> o2) {
                    return o2.getKey().compareTo(o1.getKey());
                }
            };

    // Sort.
    Collections.sort(list, comp);

    // Modify the original array so that its elements are in
    // the prescribed order.
    // Retrieve indices of original locations.
    final int[] indices = new int[len];
    for (int i = 0; i < len; i++) {
        final Pair<Double, Integer> e = list.get(i);
        x[i] = e.getKey();
        indices[i] = e.getValue();
    }

    // In each of the associated arrays, move the
    // elements to their new location.
    for (int j = 0; j < yListLen; j++) {
        // Input array will be modified in place.
        final double[] yInPlace = yList[j];
        final double[] yOrig = yInPlace.clone();

        for (int i = 0; i < len; i++) {
            yInPlace[i] = yOrig[indices[i]];
        }
    }
}

From source file:org.hakkit.plugin.PluginManager.java

public Event fireEvent(Event event) {
    if (event == null)
        throw new NullArgumentException();

    for (Plugin plugin : this.loadedPlugins) {
        try {//from  w ww .jav a 2  s  .c  om
            plugin.getEventManager().fireEvent(event);
        } catch (Exception e) {
            this.server.getLogger().error("Error passing event " + event.getClass().getSimpleName()
                    + " to plugin " + plugin.getName() + "!", e);
        }
    }

    return event;
}