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.ParRateNodeSensitivityCalculator.java
public static ParRateNodeSensitivityCalculator using( final InstrumentDerivativeVisitorAdapter<YieldCurveBundle, Map<String, List<DoublesPair>>> parRateSensitivityCalculator) { Validate.notNull(parRateSensitivityCalculator, "par rate sensitivity calculator"); return new ParRateNodeSensitivityCalculator(parRateSensitivityCalculator); }
From source file:de.thejeterlp.bukkit.login.SQLAccount.java
protected static Account convert(UUID uuid) throws SQLException { checkReflection();//from w ww . java 2s .c o m Validate.notNull(uuid, "uuid cannot be null!"); PreparedStatement st = Login.getInstance().getDB() .getPreparedStatement("SELECT * FROM `" + Statics.USER_TABLE + "` WHERE `uuid` = ? LIMIT 1;"); st.setString(1, uuid.toString()); ResultSet rs = st.executeQuery(); while (rs.next()) { int id = rs.getInt("id"); Login.getInstance().getDB().closeResultSet(rs); Login.getInstance().getDB().closeStatement(st); PreparedStatement sta = Login.getInstance().getDB().getPreparedStatement( "SELECT * FROM `" + Statics.PASSWORD_TABLE + "` WHERE `userID` = ? LIMIT 1;"); sta.setInt(1, id); ResultSet rset = sta.executeQuery(); while (rset.next()) { String hash = rset.getString("password"); Login.getInstance().getDB().closeResultSet(rset); Login.getInstance().getDB().closeStatement(sta); return new Account(id, uuid, hash); } } return null; }
From source file:com.opengamma.core.region.RegionUtils.java
/** * Creates a set of regions from a region id. * This is useful in the case where the region is compound (e.g. NY+LON). * //www . j a va 2 s . c o m * @param regionSource The region source, not null * @param regionId The region id, not null * @return a set of the region(s) */ public static Set<Region> getRegions(RegionSource regionSource, final ExternalId regionId) { Validate.notNull(regionSource, "region source"); Validate.notNull(regionId, "region id"); if (regionId.isScheme(ExternalSchemes.FINANCIAL) && regionId.getValue().contains("+")) { final String[] regions = regionId.getValue().split("\\+"); final Set<Region> resultRegions = new HashSet<Region>(); for (final String region : regions) { resultRegions.add(regionSource.getHighestLevelRegion(ExternalSchemes.financialRegionId(region))); } return resultRegions; } return Collections.singleton(regionSource.getHighestLevelRegion(regionId)); }
From source file:com.opengamma.financial.convention.INConventions.java
public static synchronized void addFixedIncomeInstrumentConventions( final InMemoryConventionBundleMaster 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 semiAnnual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.SEMI_ANNUAL_NAME); final Frequency annual = SimpleFrequencyFactory.INSTANCE.getFrequency(Frequency.ANNUAL_NAME); final ExternalId in = ExternalSchemes.financialRegionId("IN"); final Integer overnightPublicationLag = 0; final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster); // IR FUTURES utils.addConventionBundle(//from w w w . j a v a 2 s . c om ExternalIdBundle .of(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "INR_IR_FUTURE")), "INR_IR_FUTURE", act365, modified, Period.ofMonths(3), 0, true, in); utils.addConventionBundle( ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId("IRNI6M Curncy"), ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "INR SWAP INDEX")), "INR SWAP INDEX", act365, modified, Period.ofMonths(6), 0, true, in); utils.addConventionBundle( ExternalIdBundle.of(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "INR_SWAP")), "INR_SWAP", act365, modified, semiAnnual, 0, in, act365, modified, semiAnnual, 0, ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "INR SWAP INDEX"), in, true); utils.addConventionBundle( ExternalIdBundle .of(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "INR_6M_SWAP")), "INR_6M_SWAP", act365, modified, semiAnnual, 0, in, act365, modified, semiAnnual, 0, ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "INR SWAP INDEX"), in, true); utils.addConventionBundle( ExternalIdBundle .of(ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "INR_OIS_SWAP")), "INR_OIS_SWAP", act365, modified, annual, 0, in, act365, modified, annual, 0, ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "INR OVERNIGHT CASH RATE"), in, true, overnightPublicationLag); utils.addConventionBundle( ExternalIdBundle.of(ExternalSchemes.bloombergTickerSecurityId("NSERO Index"), ExternalId.of(InMemoryConventionBundleMaster.SIMPLE_NAME_SCHEME, "INR OVERNIGHT CASH RATE")), "INR OVERNIGHT CASH RATE", act365, following, Period.ofDays(1), 0, false, in, 0); }
From source file:com.opengamma.analytics.math.surface.SurfaceSliceFunction.java
public static Curve<Double, Double> cut(final Surface<Double, Double, Double> surface, final Axis axis, final Double at, final Interpolator1D interpolator) { Validate.notNull(surface, "surface"); Validate.notNull(axis, "axis"); Validate.notNull(at, "at"); if (axis == Axis.X) { Double[] yData = surface.getYData(); int nPoints = yData.length; Double[] zData = new Double[nPoints]; for (int i = 0; i < nPoints; i++) { zData[i] = surface.getZValue(at, yData[i]); }/* w w w. j av a 2 s. c om*/ return InterpolatedDoublesCurve.from(yData, zData, interpolator); } else if (axis == Axis.Y) { Double[] xData = surface.getXData(); int nPoints = xData.length; Double[] zData = new Double[nPoints]; for (int i = 0; i < nPoints; i++) { zData[i] = surface.getZValue(at, xData[i]); } return InterpolatedDoublesCurve.from(xData, zData, interpolator); } return null; // FIXME Need an example of how to throw exceptions. }
From source file:com.opengamma.analytics.financial.interestrate.capletstripping.CapFloorDecomposer.java
/** * Express a cap or floor as a strip of European call or put options * @param cap The cap or floor//from ww w .j av a 2 s . co m * @param ycb yield curves (i.e. discount and Ibor-projection curves) * @return strip of European call or put options */ public static SimpleOptionData[] toOptions(final CapFloor cap, final YieldCurveBundle ycb) { Validate.notNull(cap, "null cap"); return toOptions(cap.getPayments(), ycb); }
From source file:de.matzefratze123.staffinformer.util.IOUtil.java
public static void copy(InputStream stream, File output) throws IOException { Validate.notNull(stream, "InputStream cannot be null"); Validate.notNull(output, "Output file cannot be null"); final int BUFFER_SIZE = 1024; OutputStream outStream = null; try {//w ww . ja va2s . co m if (!output.exists()) { output.createNewFile(); } outStream = new FileOutputStream(output); byte[] buffer = new byte[BUFFER_SIZE]; int read; while ((read = stream.read(buffer)) > 0) { outStream.write(buffer, 0, read); } outStream.flush(); } finally { try { if (stream != null) { stream.close(); } if (outStream != null) { outStream.close(); } } catch (Exception e) { } } }
From source file:com.opengamma.analytics.math.ParallelArrayBinarySort.java
/** * Sort the content of keys and values simultaneously so that * both match the correct ordering. Alters the arrays in place * @param keys The keys/*from www .j a v a2s . com*/ * @param values The values */ public static void parallelBinarySort(final double[] keys, final double[] values) { Validate.notNull(keys, "x data"); Validate.notNull(values, "y data"); Validate.isTrue(keys.length == values.length); final int n = keys.length; dualArrayQuickSort(keys, values, 0, n - 1); }
From source file:com.opengamma.financial.convention.BRConventions.java
public static synchronized void addFixedIncomeInstrumentConventions( final InMemoryConventionBundleMaster conventionMaster) { Validate.notNull(conventionMaster, "convention master"); final BusinessDayConvention following = BusinessDayConventionFactory.INSTANCE .getBusinessDayConvention("Following"); final DayCount dc = DayCountFactory.INSTANCE.getDayCount("28/360"); final ExternalId mx = ExternalSchemes.financialRegionId("MX"); final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster); utils.addConventionBundle(/*from w w w .j a va 2 s . c o m*/ ExternalIdBundle.of(bloombergTickerSecurityId("MPDR1T Curncy"), simpleNameSecurityId("MXN DEPOSIT 1d")), "MXN DEPOSIT 1d", dc, following, Period.ofDays(1), 0, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDR2T Curncy"), simpleNameSecurityId("MXN DEPOSIT 2d")), "MXN DEPOSIT 2d", dc, following, Period.ofDays(1), 0, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDR3T Curncy"), simpleNameSecurityId("MXN DEPOSIT 3d")), "MXN DEPOSIT 3d", dc, following, Period.ofDays(1), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDR1Z Curncy"), simpleNameSecurityId("MXN DEPOSIT 1w")), "MXN DEPOSIT 1w", dc, following, Period.ofDays(7), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDR2Z Curncy"), simpleNameSecurityId("MXN DEPOSIT 2w")), "MXN DEPOSIT 2w", dc, following, Period.ofDays(14), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDR3Z Curncy"), simpleNameSecurityId("MXN DEPOSIT 3w")), "MXN DEPOSIT 3w", dc, following, Period.ofDays(21), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDRA Curncy"), simpleNameSecurityId("MXN DEPOSIT 1m")), "MXN DEPOSIT 1m", dc, following, Period.ofMonths(1), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDRB Curncy"), simpleNameSecurityId("MXN DEPOSIT 2m")), "MXN DEPOSIT 2m", dc, following, Period.ofMonths(2), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDRC Curncy"), simpleNameSecurityId("MXN DEPOSIT 3m")), "MXN DEPOSIT 3m", dc, following, Period.ofMonths(3), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDRD Curncy"), simpleNameSecurityId("MXN DEPOSIT 4m")), "MXN DEPOSIT 4m", dc, following, Period.ofMonths(4), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDRE Curncy"), simpleNameSecurityId("MXN DEPOSIT 5m")), "MXN DEPOSIT 5m", dc, following, Period.ofMonths(5), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDRF Curncy"), simpleNameSecurityId("MXN DEPOSIT 6m")), "MXN DEPOSIT 6m", dc, following, Period.ofMonths(6), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDRG Curncy"), simpleNameSecurityId("MXN DEPOSIT 7m")), "MXN DEPOSIT 7m", dc, following, Period.ofMonths(7), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDRH Curncy"), simpleNameSecurityId("MXN DEPOSIT 8m")), "MXN DEPOSIT 8m", dc, following, Period.ofMonths(8), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDRI Curncy"), simpleNameSecurityId("MXN DEPOSIT 9m")), "MXN DEPOSIT 9m", dc, following, Period.ofMonths(9), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDRJ Curncy"), simpleNameSecurityId("MXN DEPOSIT 10m")), "MXN DEPOSIT 10m", dc, following, Period.ofMonths(10), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDRK Curncy"), simpleNameSecurityId("MXN DEPOSIT 11m")), "MXN DEPOSIT 11m", dc, following, Period.ofMonths(11), 2, false, mx); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("MPDR1 Curncy"), simpleNameSecurityId("MXN DEPOSIT 12m")), "MXN DEPOSIT 12m", dc, following, Period.ofMonths(12), 2, false, mx); }
From source file:com.opengamma.financial.convention.MXConventions.java
public static synchronized void addFixedIncomeInstrumentConventions( final InMemoryConventionBundleMaster conventionMaster) { Validate.notNull(conventionMaster, "convention master"); final BusinessDayConvention following = BusinessDayConventionFactory.INSTANCE .getBusinessDayConvention("Following"); final DayCount act252 = DayCountFactory.INSTANCE.getDayCount("Actual/252"); final ExternalId br = ExternalSchemes.financialRegionId("BR"); final ConventionBundleMasterUtils utils = new ConventionBundleMasterUtils(conventionMaster); utils.addConventionBundle(/*from www . ja v a 2 s .c om*/ ExternalIdBundle.of(bloombergTickerSecurityId("BCDR1T Curncy"), simpleNameSecurityId("BRL DEPOSIT 1d")), "BRL DEPOSIT 1d", act252, following, Period.ofDays(1), 0, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDR2T Curncy"), simpleNameSecurityId("BRL DEPOSIT 2d")), "BRL DEPOSIT 2d", act252, following, Period.ofDays(1), 0, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDR3T Curncy"), simpleNameSecurityId("BRL DEPOSIT 3d")), "BRL DEPOSIT 3d", act252, following, Period.ofDays(1), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDR1Z Curncy"), simpleNameSecurityId("BRL DEPOSIT 1w")), "BRL DEPOSIT 1w", act252, following, Period.ofDays(7), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDR2Z Curncy"), simpleNameSecurityId("BRL DEPOSIT 2w")), "BRL DEPOSIT 2w", act252, following, Period.ofDays(14), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDR3Z Curncy"), simpleNameSecurityId("BRL DEPOSIT 3w")), "BRL DEPOSIT 3w", act252, following, Period.ofDays(21), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDRA Curncy"), simpleNameSecurityId("BRL DEPOSIT 1m")), "BRL DEPOSIT 1m", act252, following, Period.ofMonths(1), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDRB Curncy"), simpleNameSecurityId("BRL DEPOSIT 2m")), "BRL DEPOSIT 2m", act252, following, Period.ofMonths(2), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDRC Curncy"), simpleNameSecurityId("BRL DEPOSIT 3m")), "BRL DEPOSIT 3m", act252, following, Period.ofMonths(3), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDRD Curncy"), simpleNameSecurityId("BRL DEPOSIT 4m")), "BRL DEPOSIT 4m", act252, following, Period.ofMonths(4), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDRE Curncy"), simpleNameSecurityId("BRL DEPOSIT 5m")), "BRL DEPOSIT 5m", act252, following, Period.ofMonths(5), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDRF Curncy"), simpleNameSecurityId("BRL DEPOSIT 6m")), "BRL DEPOSIT 6m", act252, following, Period.ofMonths(6), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDRG Curncy"), simpleNameSecurityId("BRL DEPOSIT 7m")), "BRL DEPOSIT 7m", act252, following, Period.ofMonths(7), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDRH Curncy"), simpleNameSecurityId("BRL DEPOSIT 8m")), "BRL DEPOSIT 8m", act252, following, Period.ofMonths(8), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDRI Curncy"), simpleNameSecurityId("BRL DEPOSIT 9m")), "BRL DEPOSIT 9m", act252, following, Period.ofMonths(9), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDRJ Curncy"), simpleNameSecurityId("BRL DEPOSIT 10m")), "BRL DEPOSIT 10m", act252, following, Period.ofMonths(10), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDRK Curncy"), simpleNameSecurityId("BRL DEPOSIT 11m")), "BRL DEPOSIT 11m", act252, following, Period.ofMonths(11), 2, false, br); utils.addConventionBundle( ExternalIdBundle.of(bloombergTickerSecurityId("BCDR1 Curncy"), simpleNameSecurityId("BRL DEPOSIT 12m")), "BRL DEPOSIT 12m", act252, following, Period.ofMonths(12), 2, false, br); }