List of usage examples for org.apache.commons.lang Validate notNull
public static void notNull(Object object, String message)
Validate an argument, throwing IllegalArgumentException
if the argument is null
.
Validate.notNull(myObject, "The object must not be null");
From source file:de.xaniox.heavyspleef.core.collection.DualMaps.java
@SuppressWarnings("unchecked") public static <K1, K2, V, MV> DualKeyBiMap<K1, K2, MV> valueMappedImmutableDualBiMap( DualKeyBiMap<K1, K2, V> map, Mapper<V, MV> mapper) { Validate.notNull(map, "Map cannot be null"); Validate.notNull(mapper, "Mapper cannot be null"); Set<Entry<DualKeyPair<K1, K2>, V>> entries = map.entrySet(); DualKeyBiMap<K1, K2, MV> mappedMap = new DualKeyHashBiMap<K1, K2, MV>(map.getPrimaryKeyClass(), map.getSecondaryKeyClass()); for (Entry<DualKeyPair<K1, K2>, V> entry : entries) { V val = entry.getValue(); MV mapped = mapper.map(val); mappedMap.put((DualKeyPair<K1, K2>) entry.getKey().clone(), mapped); }/*from w w w . j a v a 2 s . c o m*/ return immutableDualBiMap(mappedMap); }
From source file:com.opengamma.analytics.math.statistics.descriptive.LognormalPearsonKurtosisFromVolatilityCalculator.java
@Override public Double evaluate(final Double sigma, final Double t) { Validate.notNull(sigma, "sigma"); Validate.notNull(t, "t"); return CALCULATOR.evaluate(sigma, t) + 3; }
From source file:com.evolveum.midpoint.repo.sql.data.common.any.RValueType.java
public static RValueType getTypeFromItemClass(Class<? extends Item> clazz) { Validate.notNull(clazz, "Class must not be null."); for (RValueType value : RValueType.values()) { if (value.getItemClass().isAssignableFrom(clazz)) { return value; }// w w w . java 2 s.c o m } throw new IllegalArgumentException("Unknown enum value type for '" + clazz.getName() + "'."); }
From source file:com.opengamma.analytics.math.function.special.KroneckerDeltaFunction.java
@Override public Integer evaluate(Integer i, Integer j) { Validate.notNull(i, "i"); Validate.notNull(j, "j"); return i.intValue() == j.intValue() ? 1 : 0; }
From source file:com.opengamma.analytics.math.surface.ConstantSurfaceAdditiveShiftFunction.java
/** * {@inheritDoc}// ww w. j a va2 s . c o m */ @Override public ConstantDoublesSurface evaluate(final ConstantDoublesSurface surface, final double shift) { Validate.notNull(surface, "surface"); return evaluate(surface, shift, "PARALLEL_SHIFT_" + surface.getName()); }
From source file:com.opengamma.analytics.math.statistics.descriptive.robust.SampleMedianAbsoluteDeviationCalculator.java
@Override public Double evaluate(final double[] x) { Validate.notNull(x, "x"); final int n = x.length; Validate.isTrue(n > 1, "Need at least two data points to calculate MAD"); final double median = MEDIAN.evaluate(x); final double[] diff = new double[n]; for (int i = 0; i < n; i++) { diff[i] = Math.abs(x[i] - median); }/*from w w w. j a v a 2 s. c o m*/ return MEDIAN.evaluate(diff); }
From source file:com.opengamma.financial.analytics.conversion.BondFutureTradeConverter.java
public BondFutureTradeConverter(final BondFutureSecurityConverter securityConverter) { Validate.notNull(securityConverter, "security converter"); _securityConverter = securityConverter; }
From source file:com.opengamma.analytics.math.interpolation.StepInterpolator1D.java
@Override public Double interpolate(final Interpolator1DDataBundle data, final Double value) { Validate.notNull(value, "value"); Validate.notNull(data, "data bundle"); return data.get(data.getLowerBoundKey(value)); }
From source file:com.opengamma.examples.convention.SyntheticUSConventions.java
public static synchronized void addFixedIncomeInstrumentConventions( final ConventionBundleMaster conventionMaster) { Validate.notNull(conventionMaster, "convention master"); final BusinessDayConvention modified = BusinessDayConventionFactory.INSTANCE .getBusinessDayConvention("Modified Following"); final BusinessDayConvention following = BusinessDayConventionFactory.INSTANCE .getBusinessDayConvention("Following"); final DayCount act360 = DayCountFactory.INSTANCE.getDayCount("Actual/360"); final DayCount thirty360 = DayCountFactory.INSTANCE.getDayCount("30/360"); final Frequency semiAnnual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME); final Frequency quarterly = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME); final ExternalId usgb = ExternalSchemes.financialRegionId("US+GB"); final ExternalId us = ExternalSchemes.financialRegionId("US"); final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster); //LIBOR//from w w w . java 2s .c om utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("USDLIBORP7D"), simpleNameSecurityId("USD LIBOR 7d")), "USD LIBOR 7d", act360, modified, Period.ofDays(7), 2, false, us); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("USDLIBORP14D"), simpleNameSecurityId("USD LIBOR 14d")), "USD LIBOR 14d", act360, modified, Period.ofDays(14), 2, false, us); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("USDLIBORP1M"), simpleNameSecurityId("USD LIBOR 1m")), "USD LIBOR 1m", act360, modified, Period.ofMonths(1), 2, false, us); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("USDLIBORP2M"), simpleNameSecurityId("USD LIBOR 2m")), "USD LIBOR 2m", act360, modified, Period.ofMonths(2), 2, false, us); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("USDLIBORP3M"), simpleNameSecurityId("USD LIBOR 3m")), "USD LIBOR 3m", act360, modified, Period.ofMonths(3), 2, false, us); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("USDLIBORP6M"), simpleNameSecurityId("USD LIBOR 6m")), "USD LIBOR 6m", act360, modified, Period.ofMonths(6), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDLIBORP12M")), "USD LIBOR 12m", act360, modified, Period.ofMonths(12), 2, false, us); final DayCount swapFixedDayCount = thirty360; final BusinessDayConvention swapFixedBusinessDay = modified; final Frequency swapFixedPaymentFrequency = semiAnnual; final DayCount swapFloatDayCount = act360; final BusinessDayConvention swapFloatBusinessDay = modified; final Frequency swapFloatPaymentFrequency = quarterly; final Frequency annual = PeriodFrequency.ANNUAL; final int[] isdaFixTenor = new int[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 15, 20, 25, 30 }; // ISDA fixing 11.00 New-York for (final int element : isdaFixTenor) { final String tenorString = element + "Y"; final String sytheticID = "USDISDA10P" + tenorString; utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId(sytheticID)), "USD_ISDAFIX_USDLIBOR10_" + tenorString, swapFixedDayCount, swapFixedBusinessDay, swapFixedPaymentFrequency, 2, us, act360, modified, semiAnnual, 2, simpleNameSecurityId("USD LIBOR 3m"), us, true, Period.ofYears(element)); } utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP1D")), "USDCASHP1D", act360, following, Period.ofDays(1), 0, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP2D")), "USDCASHP2D", act360, following, Period.ofDays(2), 0, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP1M")), "USDCASHP1M", act360, modified, Period.ofMonths(1), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP2M")), "USDCASHP2M", act360, modified, Period.ofMonths(2), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP3M")), "USDCASHP3M", act360, modified, Period.ofMonths(3), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP4M")), "USDCASHP4M", act360, modified, Period.ofMonths(4), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP5M")), "USDCASHP5M", act360, modified, Period.ofMonths(5), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP6M")), "USDCASHP6M", act360, modified, Period.ofMonths(6), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP7M")), "USDCASHP7M", act360, modified, Period.ofMonths(7), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP8M")), "USDCASHP8M", act360, modified, Period.ofMonths(8), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP9M")), "USDCASHP9M", act360, modified, Period.ofMonths(9), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP10M")), "USDCASHP10M", act360, modified, Period.ofMonths(10), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP11M")), "USDCASHP11M", act360, modified, Period.ofMonths(11), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("USDCASHP12M")), "USDCASHP12M", act360, modified, Period.ofMonths(12), 2, false, us); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("USD_SWAP")), "USD_SWAP", swapFixedDayCount, swapFixedBusinessDay, swapFixedPaymentFrequency, 2, usgb, swapFloatDayCount, swapFloatBusinessDay, swapFloatPaymentFrequency, 2, simpleNameSecurityId("USD LIBOR 3m"), usgb, true); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("USD_3M_SWAP")), "USD_3M_SWAP", swapFixedDayCount, swapFixedBusinessDay, swapFixedPaymentFrequency, 2, usgb, swapFloatDayCount, swapFloatBusinessDay, quarterly, 2, simpleNameSecurityId("USD LIBOR 3m"), usgb, true); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("USD_6M_SWAP")), "USD_6M_SWAP", swapFixedDayCount, swapFixedBusinessDay, swapFixedPaymentFrequency, 2, usgb, swapFloatDayCount, swapFloatBusinessDay, semiAnnual, 2, simpleNameSecurityId("USD LIBOR 6m"), usgb, true); final int publicationLag = 1; // Fed Fund effective utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("USDFF"), simpleNameSecurityId("USD FF EFFECTIVE")), "USD FF EFFECTIVE", act360, following, Period.ofDays(1), 2, false, us, publicationLag); // OIS swap utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("USD_OIS_SWAP")), "USD_OIS_SWAP", thirty360, modified, annual, 2, usgb, thirty360, modified, annual, 2, simpleNameSecurityId("USD FF EFFECTIVE"), usgb, true, publicationLag); // FRA conventions are stored as IRS utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("USD_3M_FRA")), "USD_3M_FRA", thirty360, modified, quarterly, 2, usgb, act360, modified, quarterly, 2, simpleNameSecurityId("USD LIBOR 3m"), usgb, true); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("USD_6M_FRA")), "USD_6M_FRA", thirty360, modified, semiAnnual, 2, usgb, act360, modified, semiAnnual, 2, simpleNameSecurityId("USD LIBOR 6m"), usgb, true); }
From source file:com.opengamma.analytics.math.minimization.LineSearch.java
public LineSearch(final ScalarMinimizer minimizer) { Validate.notNull(minimizer, "null minimizer"); _minimizer = minimizer;//from w w w. j a v a2 s.c o m _bracketer = new ParabolicMinimumBracketer(); }