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:com.opengamma.analytics.financial.interestrate.capletstripping.CapFloorDecomposer.java
public static SimpleOptionData[] toOptions(final CapFloorIbor[] caplets, final YieldCurveBundle ycb) { Validate.noNullElements(caplets, "null caplets"); Validate.notNull(ycb, "null yield curves"); final int n = caplets.length; SimpleOptionData[] options = new SimpleOptionData[n]; for (int i = 0; i < n; i++) { final YieldAndDiscountCurve discountCurve = ycb.getCurve(caplets[i].getFundingCurveName()); double fwd = caplets[i].accept(PRC, ycb); double t = caplets[i].getFixingTime(); // Vol is at fixing time, discounting from payment. This included the year fraction double df = discountCurve.getDiscountFactor(caplets[i].getPaymentTime()) * caplets[i].getPaymentYearFraction(); options[i] = new SimpleOptionData(fwd, caplets[i].getStrike(), t, df, caplets[i].isCap()); }/*from w w w . j a v a 2 s .co m*/ return options; }
From source file:com.googlecode.markuputils.MarkupUtils.java
private static <T extends Appendable & CharSequence> void append(T buffer, String appending) { Validate.notNull(buffer, "buffer cannot be null"); try {//from w ww .jav a 2 s . c om buffer.append(appending); } catch (IOException e) { throw new RuntimeException(e); } }
From source file:net.daboross.bukkitdev.skywars.api.translations.SkyTrans.java
/** * Gets the translation for the given key and the given arguments. * * @param key The key to search for a translation of. * @param args The arguments to apply to the translation. * @return The final message to be given in game. *///from w w w . ja va 2 s . co m public static String get(TransKey key, Object... args) { Validate.notNull(key, "Key cannot be null"); if (instance == null) { return "translation-not-found[" + key.key + "]"; } if (key.args == 0) { return instance.get(key); } else if (key.args > args.length) { throw new IllegalArgumentException("Not enough args for key " + key.key); } else if (key.args < args.length) { throw new IllegalArgumentException("Too many args for key " + key.key); } else { String format = instance.get(key); try { return String.format(format, args); } catch (IllegalFormatException ex) { SkyStatic.getLogger().log(Level.SEVERE, "Translation format error. Key is '" + key.key + ", format string is '" + format + "', stacktrace:", ex); return String.format("invalid-message-format[%s][%s]", key.key, format); } } }
From source file:com.opengamma.analytics.math.statistics.descriptive.LognormalSkewnessFromVolatilityCalculator.java
@Override public Double evaluate(final Double sigma, final Double t) { Validate.notNull(sigma, "sigma"); Validate.notNull(t, "t"); final double y = Math.sqrt(Math.exp(sigma * sigma * t) - 1); return y * (3 + y * y); }
From source file:com.opengamma.analytics.math.statistics.descriptive.LognormalFisherKurtosisFromVolatilityCalculator.java
@Override public Double evaluate(final Double sigma, final Double t) { Validate.notNull(sigma, "sigma"); Validate.notNull(t, "t"); final double y = Math.sqrt(Math.exp(sigma * sigma * t) - 1); final double y2 = y * y; return y2 * (16 + y2 * (15 + y2 * (6 + y2))); }
From source file:com.opengamma.analytics.financial.sensitivity.ValueGreek.java
public ValueGreek(final Greek underlyingGreek) { Validate.notNull(underlyingGreek, "underlying greek"); _underlyingGreek = underlyingGreek; }
From source file:com.opengamma.examples.convention.SyntheticJPConventions.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 act365 = DayCountFactory.INSTANCE.getDayCount("Actual/365"); final Frequency annual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.ANNUAL_NAME); final Frequency semiAnnual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME); final Frequency quarterly = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME); final ExternalId jp = ExternalSchemes.financialRegionId("JP"); final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster); utils.addConventionBundle(/*from w w w. j a v a 2 s . co m*/ ExternalIdBundle.of(syntheticSecurityId("JPYLIBORP7D"), simpleNameSecurityId("JPY LIBOR 1w")), "JPY LIBOR 1w", act360, following, Period.ofDays(7), 2, false, jp); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("JPYLIBORP14D"), simpleNameSecurityId("JPY LIBOR 2w")), "JPY LIBOR 2w", act360, following, Period.ofDays(14), 2, false, jp); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("JPYLIBORP1M"), simpleNameSecurityId("JPY LIBOR 1m")), "JPY LIBOR 1m", act360, following, Period.ofMonths(1), 2, false, jp); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("JPYLIBORP2M"), simpleNameSecurityId("JPY LIBOR 2m")), "JPY LIBOR 2m", act360, following, Period.ofMonths(2), 2, false, jp); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("JPYLIBORP3M"), simpleNameSecurityId("JPY LIBOR 3m")), "JPY LIBOR 3m", act360, following, Period.ofMonths(3), 2, false, jp); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("JPYLIBORP6M"), simpleNameSecurityId("JPY LIBOR 6m")), "JPY LIBOR 6m", act360, following, Period.ofMonths(6), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYLIBORP12M")), "JPY LIBOR 12m", act360, following, Period.ofMonths(12), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP1D")), "JPYCASHP1D", act360, following, Period.ofDays(1), 0, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP2D")), "JPYCASHP2D", act360, following, Period.ofDays(2), 0, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP1M")), "JPYCASHP1M", act360, modified, Period.ofMonths(1), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP2M")), "JPYCASHP2M", act360, modified, Period.ofMonths(2), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP3M")), "JPYCASHP3M", act360, modified, Period.ofMonths(3), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP4M")), "JPYCASHP4M", act360, modified, Period.ofMonths(4), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP5M")), "JPYCASHP5M", act360, modified, Period.ofMonths(5), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP6M")), "JPYCASHP6M", act360, modified, Period.ofMonths(6), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP7M")), "JPYCASHP7M", act360, modified, Period.ofMonths(7), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP8M")), "JPYCASHP8M", act360, modified, Period.ofMonths(8), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP9M")), "JPYCASHP9M", act360, modified, Period.ofMonths(9), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP10M")), "JPYCASHP10M", act360, modified, Period.ofMonths(10), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP11M")), "JPYCASHP11M", act360, modified, Period.ofMonths(11), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("JPYCASHP12M")), "JPYCASHP12M", act360, modified, Period.ofMonths(12), 2, false, jp); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("JPY_SWAP")), "JPY_SWAP", act365, modified, semiAnnual, 2, jp, act360, modified, semiAnnual, 2, simpleNameSecurityId("JPY LIBOR 6m"), jp, true); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("JPY_3M_SWAP")), "JPY_3M_SWAP", act365, modified, semiAnnual, 2, jp, act360, modified, quarterly, 2, simpleNameSecurityId("JPY LIBOR 3m"), jp, true); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("JPY_6M_SWAP")), "JPY_6M_SWAP", act365, modified, semiAnnual, 2, jp, act360, modified, semiAnnual, 2, simpleNameSecurityId("JPY LIBOR 6m"), jp, true); final Integer publicationLag = 0; utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("TONAR"), simpleNameSecurityId("JPY TONAR")), "JPY TONAR", act365, following, Period.ofDays(1), 2, false, jp, publicationLag); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("JPY_OIS_SWAP")), "JPY_OIS_SWAP", act365, modified, annual, 2, jp, act365, modified, annual, 2, simpleNameSecurityId("JPY TONAR"), jp, true, publicationLag); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("JPY_3M_FRA")), "JPY_3M_FRA", act365, modified, semiAnnual, 2, jp, act360, modified, quarterly, 2, simpleNameSecurityId("JPY LIBOR 3m"), jp, true); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("JPY_6M_FRA")), "JPY_6M_FRA", act365, modified, semiAnnual, 2, jp, act360, modified, semiAnnual, 2, simpleNameSecurityId("JPY LIBOR 6m"), jp, true); }
From source file:com.opengamma.examples.convention.SyntheticCHConventions.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 quarterly = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME); final Frequency semiAnnual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME); final Frequency annual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.ANNUAL_NAME); final ExternalId ch = ExternalSchemes.financialRegionId("CH"); final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster); utils.addConventionBundle(/*from w ww . j a v a 2 s .c o m*/ ExternalIdBundle.of(syntheticSecurityId("CHFLIBORP7D"), simpleNameSecurityId("CHF LIBOR 7d")), "CHF LIBOR 7d", act360, following, Period.ofDays(7), 2, false, ch); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("CHFLIBORP14D"), simpleNameSecurityId("CHF LIBOR 14d")), "CHF LIBOR 14d", act360, following, Period.ofDays(14), 2, false, ch); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("CHFLIBORP1M"), simpleNameSecurityId("CHF LIBOR 1m")), "CHF LIBOR 1m", act360, following, Period.ofMonths(1), 2, false, ch); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("CHFLIBORP2M"), simpleNameSecurityId("CHF LIBOR 2m")), "CHF LIBOR 2m", act360, following, Period.ofMonths(2), 2, false, ch); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("CHFLIBORP3M"), simpleNameSecurityId("CHF LIBOR 3m")), "CHF LIBOR 3m", act360, following, Period.ofMonths(3), 2, false, ch); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("CHFLIBORP6M"), simpleNameSecurityId("CHF LIBOR 6m")), "CHF LIBOR 6m", act360, following, Period.ofMonths(6), 2, false, ch); utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("CHFLIBORP12M"), simpleNameSecurityId("CHF LIBOR 12m")), "CHF LIBOR 6m", act360, following, Period.ofMonths(12), 2, false, ch); //Identifiers for external data utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP1D")), "CHFCASHP1D", act360, following, Period.ofDays(1), 0, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP2D")), "CHFCASHP2D", act360, following, Period.ofDays(2), 0, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP1M")), "CHFCASHP1M", act360, modified, Period.ofMonths(1), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP2M")), "CHFCASHP2M", act360, modified, Period.ofMonths(2), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP3M")), "CHFCASHP3M", act360, modified, Period.ofMonths(3), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP4M")), "CHFCASHP4M", act360, modified, Period.ofMonths(4), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP5M")), "CHFCASHP5M", act360, modified, Period.ofMonths(5), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP6M")), "CHFCASHP6M", act360, modified, Period.ofMonths(6), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP7M")), "CHFCASHP7M", act360, modified, Period.ofMonths(7), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP8M")), "CHFCASHP8M", act360, modified, Period.ofMonths(8), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP9M")), "CHFCASHP9M", act360, modified, Period.ofMonths(9), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP10M")), "CHFCASHP10M", act360, modified, Period.ofMonths(10), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP11M")), "CHFCASHP11M", act360, modified, Period.ofMonths(11), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CHFCASHP12M")), "CHFCASHP12M", act360, modified, Period.ofMonths(12), 2, false, ch); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_SWAP")), "CHF_SWAP", thirty360, modified, annual, 2, ch, act360, modified, semiAnnual, 2, simpleNameSecurityId("CHF LIBOR 6m"), ch, true); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_3M_SWAP")), "CHF_3M_SWAP", thirty360, modified, annual, 2, ch, act360, modified, quarterly, 2, simpleNameSecurityId("CHF LIBOR 3m"), ch, true); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_6M_SWAP")), "CHF_6M_SWAP", thirty360, modified, annual, 2, ch, act360, modified, semiAnnual, 2, simpleNameSecurityId("CHF LIBOR 6m"), ch, true); final Integer publicationLagON = 0; utils.addConventionBundle( ExternalIdBundle.of(syntheticSecurityId("TOISTOIS"), simpleNameSecurityId("CHF TOISTOIS")), "CHF TOISTOIS", act360, following, Period.ofDays(1), 2, false, ch, publicationLagON); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_OIS_SWAP")), "CHF_OIS_SWAP", act360, modified, annual, 2, ch, act360, modified, annual, 2, simpleNameSecurityId("CHF TOISTOIS"), ch, true, publicationLagON); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_3M_FRA")), "CHF_3M_FRA", thirty360, modified, annual, 2, ch, act360, modified, quarterly, 2, simpleNameSecurityId("CHF LIBOR 3m"), ch, true); utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CHF_6M_FRA")), "CHF_6M_FRA", thirty360, modified, annual, 2, ch, act360, modified, semiAnnual, 2, simpleNameSecurityId("CHF LIBOR 6m"), ch, true); }
From source file:com.opengamma.analytics.financial.sensitivity.PositionGreek.java
public PositionGreek(final Greek underlyingGreek) { Validate.notNull(underlyingGreek, "underlying greek"); _underlyingGreek = underlyingGreek; }
From source file:com.opengamma.analytics.util.surface.StringValue.java
/** * Builder from on point./* w ww.ja va 2 s . com*/ * @param point The surface point. * @param value The associated value. * @return The surface value. */ public static StringValue from(final String point, final Double value) { Validate.notNull(point, "Point"); HashMap<String, Double> data = new HashMap<String, Double>(); data.put(point, value); return new StringValue(data); }