Example usage for org.apache.commons.lang Validate notNull

List of usage examples for org.apache.commons.lang Validate notNull

Introduction

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

Prototype

public static void notNull(Object object, String message) 

Source Link

Document

Validate an argument, throwing IllegalArgumentException if the argument is null.

 Validate.notNull(myObject, "The object must not be null"); 

Usage

From source file:com.github.fritaly.graphml4j.Utils.java

/**
 * Encodes the given color into an hexadecimal string like "#RRGGBBAA" or
 * "#RRGGBB" (whether the transparency is set to 0).
 *
 * @param color/* ww w. ja  v  a2  s.  c om*/
 *            a color to encode. Can't be null.
 * @return a string representing the encoded color.
 */
static String encode(Color color) {
    Validate.notNull(color, "The given color is null");

    if (color.getAlpha() == 255) {
        return String.format("#%02X%02X%02X", color.getRed(), color.getGreen(), color.getBlue());
    } else {
        return String.format("#%02X%02X%02X%02X", color.getRed(), color.getGreen(), color.getBlue(),
                color.getAlpha());
    }
}

From source file:com.opengamma.examples.convention.SyntheticCAConventions.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 ca = ExternalSchemes.financialRegionId("CA");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);

    utils.addConventionBundle(//from   w w  w.  j  a  v  a  2s  .c  om
            ExternalIdBundle.of(syntheticSecurityId("CADLIBORP3M"), simpleNameSecurityId("CDOR 3m")),
            "CAD LIBOR 3m", act360, following, Period.ofMonths(3), 2, false, ca);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CADLIBORP6M")), "CAD LIBOR 6m", act360,
            following, Period.ofMonths(6), 2, false, ca);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("CADLIBORP12M")), "CAD LIBOR 12m", act360,
            following, Period.ofMonths(12), 2, false, ca);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CAD_SWAP")), "CAD_SWAP", act365,
            modified, semiAnnual, 0, ca, act365, modified, quarterly, 0, simpleNameSecurityId("CDOR 3m"), ca,
            true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("CAD_1Y_SWAP")), "CAD_1Y_SWAP", act365,
            modified, annual, 0, ca, act365, modified, quarterly, 0, simpleNameSecurityId("CDOR 3m"), ca, true);
}

From source file:com.opengamma.financial.convention.SEConventions.java

public static 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 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 se = ExternalSchemes.financialRegionId("SE");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);

    utils.addConventionBundle(//  ww w .j  av a 2  s. c  om
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDR1T Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 1d")),
            "SEK DEPOSIT 1d", act360, following, Period.ofDays(1), 0, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDR2T Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 2d")),
            "SEK DEPOSIT 2d", act360, following, Period.ofDays(1), 1, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDR3T Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 3d")),
            "SEK DEPOSIT 3d", act360, following, Period.ofDays(1), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDR1Z Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 1w")),
            "SEK DEPOSIT 1w", act360, following, Period.ofDays(7), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDR2Z Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 2w")),
            "SEK DEPOSIT 2w", act360, following, Period.ofDays(14), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDR3Z Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 3w")),
            "SEK DEPOSIT 3w", act360, following, Period.ofDays(21), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDRA Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 1m")),
            "SEK DEPOSIT 1m", act360, following, Period.ofMonths(1), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDRB Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 2m")),
            "SEK DEPOSIT 2m", act360, following, Period.ofMonths(2), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDRC Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 3m")),
            "SEK DEPOSIT 3m", act360, following, Period.ofMonths(3), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDRD Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 4m")),
            "SEK DEPOSIT 4m", act360, following, Period.ofMonths(4), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDRE Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 5m")),
            "SEK DEPOSIT 5m", act360, following, Period.ofMonths(5), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDRF Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 6m")),
            "SEK DEPOSIT 6m", act360, following, Period.ofMonths(6), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDRG Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 7m")),
            "SEK DEPOSIT 7m", act360, following, Period.ofMonths(7), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDRH Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 8m")),
            "SEK DEPOSIT 8m", act360, following, Period.ofMonths(8), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDRI Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 9m")),
            "SEK DEPOSIT 9m", act360, following, Period.ofMonths(9), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDRJ Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 10m")),
            "SEK DEPOSIT 10m", act360, following, Period.ofMonths(10), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDRK Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 11m")),
            "SEK DEPOSIT 11m", act360, following, Period.ofMonths(11), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDR1 Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 1y")),
            "SEK DEPOSIT 1y", act360, following, Period.ofYears(1), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDR2 Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 2y")),
            "SEK DEPOSIT 2y", act360, following, Period.ofYears(2), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDR3 Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 3y")),
            "SEK DEPOSIT 3y", act360, following, Period.ofYears(3), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDR4 Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 4y")),
            "SEK DEPOSIT 4y", act360, following, Period.ofYears(4), 2, false, se);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("SKDR5 Curncy"),
                    simpleNameSecurityId("SEK DEPOSIT 5y")),
            "SEK DEPOSIT 5y", act360, following, Period.ofYears(5), 2, false, se);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("SEK_SWAP")), "SEK_SWAP", thirty360,
            modified, annual, 1, se, act360, modified, quarterly, 1, simpleNameSecurityId("SEK DEPOSIT 3m"), se,
            true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("SEK_3M_SWAP")), "SEK_3M_SWAP",
            thirty360, modified, annual, 2, se, act360, modified, quarterly, 2,
            simpleNameSecurityId("SEK DEPOSIT 3m"), se, true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("SEK_6M_SWAP")), "SEK_6M_SWAP",
            thirty360, modified, annual, 2, se, act360, modified, semiAnnual, 2,
            simpleNameSecurityId("SEK DEPOSIT 6m"), se, true);

}

From source file:com.opengamma.analytics.math.TrigonometricFunctionUtils.java

public static ComplexNumber acosh(final ComplexNumber z) {
    Validate.notNull(z, "z");
    return ComplexMathUtils.log(ComplexMathUtils.add(z,
            ComplexMathUtils.sqrt(ComplexMathUtils.subtract(ComplexMathUtils.multiply(z, z), 1))));
}

From source file:com.stealthyone.mcb.stbukkitlib.utils.FileUtils.java

public static File copyFileFromJar(JavaPlugin plugin, String fileName, File destination) throws IOException {
    Validate.notNull(plugin, "Plugin cannot be null.");
    Validate.notNull(fileName, "File name cannot be null.");
    Validate.notNull(destination, "Destination cannot be null.");

    InputStream in = plugin.getResource(fileName);
    if (in == null)
        throw new FileNotFoundException(
                "Unable to find file '" + fileName + "' in jar for plugin: '" + plugin.getName() + "'");

    OutputStream out = new FileOutputStream(destination);
    byte[] buf = new byte[1024];
    int len;//from  w w  w .  j a v a  2 s  .  co m
    while ((len = in.read(buf)) > 0) {
        out.write(buf, 0, len);
    }
    out.close();
    in.close();
    return destination;
}

From source file:com.opengamma.examples.convention.SyntheticDKConventions.java

public static 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 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 dk = ExternalSchemes.financialRegionId("DK");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);

    utils.addConventionBundle(/* w w w .  ja  v a 2  s  .c o m*/
            ExternalIdBundle.of(syntheticSecurityId("DKKLIBORP3M"), simpleNameSecurityId("DKK CIBOR 3m")),
            "DKK CIBOR 3m", act360, following, Period.ofMonths(3), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(syntheticSecurityId("DKKLIBORP6M"), simpleNameSecurityId("DKK CIBOR 6m")),
            "DKK CIBOR 6m", act360, following, Period.ofMonths(6), 2, false, dk);

    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP1D")), "DKKCASHP1D", act360,
            following, Period.ofDays(1), 0, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP1M")), "DKKCASHP1M", act360,
            modified, Period.ofMonths(1), 2, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP2M")), "DKKCASHP2M", act360,
            modified, Period.ofMonths(2), 2, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP3M")), "DKKCASHP3M", act360,
            modified, Period.ofMonths(3), 2, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP4M")), "DKKCASHP4M", act360,
            modified, Period.ofMonths(4), 2, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP5M")), "DKKCASHP5M", act360,
            modified, Period.ofMonths(5), 2, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP6M")), "DKKCASHP6M", act360,
            modified, Period.ofMonths(6), 2, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP7M")), "DKKCASHP7M", act360,
            modified, Period.ofMonths(7), 2, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP8M")), "DKKCASHP8M", act360,
            modified, Period.ofMonths(8), 2, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP9M")), "DKKCASHP9M", act360,
            modified, Period.ofMonths(9), 2, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP10M")), "DKKCASHP10M", act360,
            modified, Period.ofMonths(10), 2, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP11M")), "DKKCASHP11M", act360,
            modified, Period.ofMonths(11), 2, false, dk);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("DKKCASHP12M")), "DKKCASHP12M", act360,
            modified, Period.ofMonths(12), 2, false, dk);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("DKK_SWAP")), "DKK_SWAP", thirty360,
            modified, annual, 1, dk, act360, modified, semiAnnual, 1, simpleNameSecurityId("DKK CIBOR 6m"), dk,
            true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("DKK_3M_SWAP")), "DKK_3M_SWAP",
            thirty360, modified, annual, 2, dk, act360, modified, quarterly, 2,
            simpleNameSecurityId("DKK CIBOR 3m"), dk, true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("DKK_6M_SWAP")), "DKK_6M_SWAP",
            thirty360, modified, annual, 2, dk, act360, modified, semiAnnual, 2,
            simpleNameSecurityId("DKK CIBOR 6m"), dk, true);
}

From source file:com.prowidesoftware.swift.model.MessageIOType.java

public static boolean isValid(String ioType) {
    Validate.notNull(ioType, "ioType can not be null");
    for (MessageIOType t : values()) {
        if (StringUtils.equals(ioType.trim(), t.name()))
            return true;
    }//from   ww  w. j  ava  2 s.  co  m
    return false;
}

From source file:com.opengamma.financial.convention.NOConventions.java

public static 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 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 dk = ExternalSchemes.financialRegionId("NO");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);

    utils.addConventionBundle(//from  w ww  . j  ava  2 s  .c om
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDR1T Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 1d")),
            "NOK DEPOSIT 1d", act360, following, Period.ofDays(1), 0, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDR2T Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 2d")),
            "NOK DEPOSIT 2d", act360, following, Period.ofDays(1), 1, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDR3T Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 3d")),
            "NOK DEPOSIT 3d", act360, following, Period.ofDays(1), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDR1Z Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 1w")),
            "NOK DEPOSIT 1w", act360, following, Period.ofDays(7), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDR2Z Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 2w")),
            "NOK DEPOSIT 2w", act360, following, Period.ofDays(14), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDR3Z Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 3w")),
            "NOK DEPOSIT 3w", act360, following, Period.ofDays(21), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDRA Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 1m")),
            "NOK DEPOSIT 1m", act360, following, Period.ofMonths(1), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDRB Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 2m")),
            "NOK DEPOSIT 2m", act360, following, Period.ofMonths(2), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDRC Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 3m")),
            "NOK DEPOSIT 3m", act360, following, Period.ofMonths(3), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDRD Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 4m")),
            "NOK DEPOSIT 4m", act360, following, Period.ofMonths(4), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDRE Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 5m")),
            "NOK DEPOSIT 5m", act360, following, Period.ofMonths(5), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDRF Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 6m")),
            "NOK DEPOSIT 6m", act360, following, Period.ofMonths(6), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDRG Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 7m")),
            "NOK DEPOSIT 7m", act360, following, Period.ofMonths(7), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDRH Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 8m")),
            "NOK DEPOSIT 8m", act360, following, Period.ofMonths(8), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDRI Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 9m")),
            "NOK DEPOSIT 9m", act360, following, Period.ofMonths(9), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDRJ Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 10m")),
            "NOK DEPOSIT 10m", act360, following, Period.ofMonths(10), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDRK Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 11m")),
            "NOK DEPOSIT 11m", act360, following, Period.ofMonths(11), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDR1 Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 1y")),
            "NOK DEPOSIT 1y", act360, following, Period.ofYears(1), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDR2 Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 2y")),
            "NOK DEPOSIT 2y", act360, following, Period.ofYears(2), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDR3 Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 3y")),
            "NOK DEPOSIT 3y", act360, following, Period.ofYears(3), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDR4 Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 4y")),
            "NOK DEPOSIT 4y", act360, following, Period.ofYears(4), 2, false, dk);
    utils.addConventionBundle(
            ExternalIdBundle.of(bloombergTickerSecurityId("NKDR5 Curncy"),
                    simpleNameSecurityId("NOK DEPOSIT 5y")),
            "NOK DEPOSIT 5y", act360, following, Period.ofYears(5), 2, false, dk);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("NOK_SWAP")), "NOK_SWAP", thirty360,
            modified, annual, 1, dk, act360, modified, semiAnnual, 1, simpleNameSecurityId("NOK DEPOSIT 6m"),
            dk, true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("NOK_3M_SWAP")), "NOK_3M_SWAP",
            thirty360, modified, annual, 2, dk, act360, modified, quarterly, 2,
            simpleNameSecurityId("NOK DEPOSIT 3m"), dk, true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("NOK_6M_SWAP")), "NOK_6M_SWAP",
            thirty360, modified, annual, 2, dk, act360, modified, semiAnnual, 2,
            simpleNameSecurityId("NOK DEPOSIT 6m"), dk, true);

}

From source file:com.opengamma.examples.convention.SyntheticNZConventions.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 act365 = DayCountFactory.INSTANCE.getDayCount("Actual/365");
    final Frequency quarterly = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.QUARTERLY_NAME);
    final Frequency semiAnnual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME);
    final ExternalId nz = ExternalSchemes.financialRegionId("NZ");

    final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster);

    utils.addConventionBundle(/*  w ww. j  a  va 2 s  .  co m*/
            ExternalIdBundle.of(syntheticSecurityId("NZDLIBORP3M"), simpleNameSecurityId("NZD LIBOR 3m")),
            "NZD LIBOR 3m", act365, following, Period.ofMonths(3), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDLIBORP6M")), "NZD LIBOR 6m", act365,
            following, Period.ofMonths(6), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDLIBORP12M")), "NZD LIBOR 12m", act365,
            following, Period.ofMonths(12), 2, false, nz);

    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP1D")), "NZDCASHP1D", act365,
            following, Period.ofDays(1), 0, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP1M")), "NZDCASHP1M", act365,
            modified, Period.ofMonths(1), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP2M")), "NZDCASHP2M", act365,
            modified, Period.ofMonths(2), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP3M")), "NZDCASHP3M", act365,
            modified, Period.ofMonths(3), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP4M")), "NZDCASHP4M", act365,
            modified, Period.ofMonths(4), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP5M")), "NZDCASHP5M", act365,
            modified, Period.ofMonths(5), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP6M")), "NZDCASHP6M", act365,
            modified, Period.ofMonths(6), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP7M")), "NZDCASHP7M", act365,
            modified, Period.ofMonths(7), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP8M")), "NZDCASHP8M", act365,
            modified, Period.ofMonths(8), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP9M")), "NZDCASHP9M", act365,
            modified, Period.ofMonths(9), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP10M")), "NZDCASHP10M", act365,
            modified, Period.ofMonths(10), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP11M")), "NZDCASHP11M", act365,
            modified, Period.ofMonths(1), 2, false, nz);
    utils.addConventionBundle(ExternalIdBundle.of(syntheticSecurityId("NZDCASHP12M")), "NZDCASHP12M", act365,
            modified, Period.ofMonths(12), 2, false, nz);

    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("NZD_SWAP")), "NZD_SWAP", act365,
            modified, semiAnnual, 2, nz, act365, modified, quarterly, 2, simpleNameSecurityId("NZD LIBOR 3m"),
            nz, true);
    utils.addConventionBundle(ExternalIdBundle.of(simpleNameSecurityId("NZD_3M_SWAP")), "NZD_3M_SWAP", act365,
            modified, semiAnnual, 2, nz, act365, modified, quarterly, 2, simpleNameSecurityId("NZD LIBOR 3m"),
            nz, true);
}

From source file:com.opengamma.analytics.financial.model.option.pricing.analytic.formula.EuropeanVanillaOption.java

public static EuropeanVanillaOption fromDefinition(final EuropeanVanillaOptionDefinition definition,
        final ZonedDateTime date) {
    Validate.notNull(definition, "definition");
    Validate.notNull(date, "date");
    return new EuropeanVanillaOption(definition.getStrike(), definition.getTimeToExpiry(date),
            definition.isCall());//from  ww w.  java 2s. com
}