/** * Adds time-series to the provider. * <p> * This adds the specified time-series to the provider. * This operates using {@link Map#putAll(Map)} semantics using the index as the key. * * @param timeSeries the FX index time-series * @return this, for chaining */ public ImmutableRatesProviderBuilder timeSeries(Map<? extends Index, LocalDateDoubleTimeSeries> timeSeries) { ArgChecker.noNulls(timeSeries, "timeSeries"); this.timeSeries.putAll(timeSeries); return this; }
/** * * @param knots the knots * @param coefMatrix the coefMatrix * @param order the order * @param dim the dim * @param coeffSense the sensitivity of the coefficients to the nodes (y-values) */ public PiecewisePolynomialResultsWithSensitivity(DoubleArray knots, DoubleMatrix coefMatrix, int order, int dim, final DoubleMatrix[] coeffSense) { super(knots, coefMatrix, order, dim); if (dim != 1) { throw new UnsupportedOperationException(); } ArgChecker.noNulls(coeffSense, "null coeffSense"); // coefficient _coeffSense = coeffSense; }
/** * Puts all the entries from the supplied map into this builder. * <p> * If a date is duplicated it will overwrite an earlier entry. * * @param map the map of points to be added * @return this builder */ public LocalDateDoubleTimeSeriesBuilder putAll(Map<LocalDate, Double> map) { ArgChecker.noNulls(map, "map"); map.entrySet().forEach(e -> put(e.getKey(), e.getValue())); return this; }
public void test_noNulls_Array_ok_empty() { Object[] array = new Object[] {}; ArgChecker.noNulls(array, "name"); }
public void test_noNulls_Array_ok() { String[] expected = new String[] {"Element"}; String[] result = ArgChecker.noNulls(expected, "name"); assertEquals(result, expected); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".*array.*'name'.*null.*") public void test_noNulls_Array_nullElement() { ArgChecker.noNulls(new Object[] {null}, "name"); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".*'name'.*null.*") public void test_noNulls_Iterable_null() { ArgChecker.noNulls((Iterable<?>) null, "name"); }
public void test_noNulls_Iterable_ok_empty() { Iterable<?> coll = Arrays.asList(); ArgChecker.noNulls(coll, "name"); }
public void test_noNulls_Map_ok_empty() { Map<Object, Object> map = new HashMap<>(); ArgChecker.noNulls(map, "name"); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".*'name'.*null.*") public void test_noNulls_Map_null() { ArgChecker.noNulls((Map<Object, Object>) null, "name"); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".*'name'.*null.*") public void test_noNulls_Array_null() { ArgChecker.noNulls((Object[]) null, "name"); }
public void test_noNulls_Iterable_ok() { List<String> expected = Arrays.asList("Element"); List<String> result = ArgChecker.noNulls(expected, "name"); assertEquals(result, expected); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".*iterable.*'name'.*null.*") public void test_noNulls_Iterable_nullElement() { ArgChecker.noNulls(Arrays.asList((Object) null), "name"); }
/** * Obtains an instance from a list of {@code CurrencyAmount} objects. * <p> * It is an error for the input to contain the same currency twice. * * @param amounts the amounts * @return the amount */ public static MultiCurrencyAmount of(Iterable<CurrencyAmount> amounts) { ArgChecker.noNulls(amounts, "amounts"); Map<Currency, CurrencyAmount> map = new HashMap<Currency, CurrencyAmount>(); for (CurrencyAmount amount : amounts) { if (map.put(amount.getCurrency(), amount) != null) { throw new IllegalArgumentException("Currency is duplicated: " + amount.getCurrency()); } } return new MultiCurrencyAmount(ImmutableSortedSet.copyOf(map.values())); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".*map.*'name'.*null.*") public void test_noNulls_Map_nullKey() { Map<Object, Object> map = new HashMap<>(); map.put("A", "B"); map.put(null, "Z"); ArgChecker.noNulls(map, "name"); }
@Test(expectedExceptions = IllegalArgumentException.class, expectedExceptionsMessageRegExp = ".*map.*'name'.*null.*") public void test_noNulls_Map_nullValue() { Map<Object, Object> map = new HashMap<>(); map.put("A", "B"); map.put("Z", null); ArgChecker.noNulls(map, "name"); }
/** * Obtains an instance from a map of currency to amount. * * @param map the map of currency to amount * @return the amount */ public static MultiCurrencyAmount of(Map<Currency, Double> map) { ArgChecker.noNulls(map, "map"); return MapStream.of(map).map(CurrencyAmount::of).collect(MultiCurrencyAmount.collectorInternal()); }
/** * Get a kth order penalty matrix for a non-uniform grid whose values have been flattened to a vector. * @param x the grid positions in each dimension * @param k the (finite difference) order * @param index which index to act on * @return a penalty matrix */ public static DoubleMatrix getPenaltyMatrix(double[][] x, int k, int index) { ArgChecker.noNulls(x, "x"); //k is checked in call below int dim = x.length; int[] numElements = new int[dim]; for (int i = 0; i < dim; i++) { numElements[i] = x[i].length; } DoubleMatrix p = getPenaltyMatrix(x[index], k); return getMatrixForFlattened(numElements, p, index); }
public void test_noNulls_Map_ok() { ImmutableSortedMap<String, String> expected = ImmutableSortedMap.of("A", "B"); ImmutableSortedMap<String, String> result = ArgChecker.noNulls(expected, "name"); assertEquals(result, expected); }
/** * Creates an instance, validating the supplied arrays. * <p> * The arrays are cloned as this constructor is called from Joda-Beans. * * @param dates the dates * @param values the values */ @ImmutableConstructor private SparseLocalDateDoubleTimeSeries(LocalDate[] dates, double[] values) { ArgChecker.noNulls(dates, "dates"); ArgChecker.notNull(values, "values"); validate(dates, values); this.dates = dates.clone(); this.values = values.clone(); }