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.hmsinc.epicenter.tools.ToolLauncher.java
/** * @param args/*from www. j a va2s . co m*/ */ public static void main(String[] args) { if (args.length > 0) { final String app = args[0]; final ConfigurableApplicationContext appContext = new ClassPathXmlApplicationContext( "classpath:" + app + "-util.xml"); final RunnableTool tool = (RunnableTool) appContext.getBean(app); Validate.notNull(tool, "Could not start tool: " + app); tool.setArguments(args); tool.run(); } }
From source file:com.opengamma.analytics.financial.timeseries.util.TimeSeriesDataTestUtils.java
/** * Tests that the time series is not null or empty * @param ts The time series//from w w w .j av a2 s . co m * @throws IllegalArgumentException If the time series is null or empty */ public static void testNotNullOrEmpty(final DoubleTimeSeries<?> ts) { Validate.notNull(ts, "time series"); Validate.isTrue(!ts.isEmpty(), "time series"); }
From source file:com.opengamma.analytics.math.util.wrapper.ColtMathWrapper.java
/** * @param x A Colt 2D matrix of doubles, not null * @return An OG 2D matrix//from ww w. ja va 2 s. c om */ public static DoubleMatrix2D wrap(final cern.colt.matrix.DoubleMatrix2D x) { Validate.notNull(x, "x"); return new DoubleMatrix2D(x.toArray()); }
From source file:com.opengamma.analytics.financial.riskfactor.TaylorExpansionMultiplierCalculator.java
public static double getMultiplier(final Underlying underlying) { Validate.notNull(underlying, "underlying"); if (underlying instanceof NthOrderUnderlying) { final NthOrderUnderlying nthOrder = (NthOrderUnderlying) underlying; final int n = nthOrder.getOrder(); if (n == 0) { return 1; }/*from www. jav a 2 s .c o m*/ return 1. / MathUtils.factorial(n); } else if (underlying instanceof MixedOrderUnderlying) { final MixedOrderUnderlying mixedOrder = (MixedOrderUnderlying) underlying; double result = 1; for (final NthOrderUnderlying underlyingOrder : mixedOrder.getUnderlyingOrders()) { result *= getMultiplier(underlyingOrder); } return result; } throw new IllegalArgumentException( "Order was neither NthOrderUnderlying nor MixedOrderUnderlying: have " + underlying.getClass()); }
From source file:com.opengamma.analytics.math.TrigonometricFunctionUtils.java
/** * arccos - the inverse of cos/*from w ww . jav a 2 s . c o m*/ * @param z A complex number * @return acos(z) */ public static ComplexNumber acos(final ComplexNumber z) { Validate.notNull(z, "z"); return ComplexMathUtils.multiply(NEGATIVE_I, ComplexMathUtils.log(ComplexMathUtils.add(z, ComplexMathUtils.sqrt(ComplexMathUtils.subtract(ComplexMathUtils.multiply(z, z), 1))))); }
From source file:com.destroystokyo.debuggery.api.DebuggeryPlayer.java
/** * Get a player object from the string provided. * The provided string can be either a UUID or a player's name * * @param string UUID or nickname to check * @return a player object if it can be found or null if it can't * @throws IllegalArgumentException if string is null *//*w w w . ja v a 2 s . co m*/ public static Player getPlayerFromString(String string) throws IllegalArgumentException { Validate.notNull(string, "String cannot be null!"); Player player; try { UUID playerUUID = UUID.fromString(string); player = Bukkit.getServer().getPlayer(playerUUID); } catch (IllegalArgumentException e) { player = Bukkit.getServer().getPlayer(string); } return player; }
From source file:com.opengamma.analytics.math.FunctionUtils.java
public static int toTensorIndex(final int[] indices, final int[] dimensions) { Validate.notNull(indices, "indices"); Validate.notNull(dimensions, "dimensions"); final int dim = indices.length; Validate.isTrue(dim == dimensions.length); int sum = 0;/*from w w w. j a v a 2 s . com*/ int product = 1; for (int i = 0; i < dim; i++) { Validate.isTrue(indices[i] < dimensions[i], "index out of bounds"); sum += indices[i] * product; product *= dimensions[i]; } return sum; }
From source file:com.opengamma.analytics.math.util.wrapper.ColtMathWrapper.java
/** * @param x An OG 2D matrix of doubles, not null * @return A Colt 2D matrix//from www . j a v a 2 s. c om */ public static cern.colt.matrix.DoubleMatrix2D wrap(final DoubleMatrix2D x) { Validate.notNull(x, "x"); return cern.colt.matrix.DoubleFactory2D.dense.make(x.getData()); }
From source file:com.opengamma.analytics.financial.schedule.ScheduleFactory.java
public static LocalDate[] getSchedule(final LocalDate startDate, final LocalDate endDate, final Frequency frequency, final boolean endOfMonth, final boolean fromEnd, final boolean generateRecursive) { Validate.notNull(startDate, "start date"); Validate.notNull(endDate, "end date"); Validate.notNull(frequency, "frequency"); SimpleFrequency simple;/*from w w w . java2s.c o m*/ if (frequency instanceof SimpleFrequency) { simple = (SimpleFrequency) frequency; } else if (frequency instanceof PeriodFrequency) { simple = ((PeriodFrequency) frequency).toSimpleFrequency(); } else { throw new IllegalArgumentException("Can only handle SimpleFrequency and PeriodFrequency"); } final int periodsPerYear = (int) simple.getPeriodsPerYear(); return getSchedule(startDate, endDate, periodsPerYear, endOfMonth, fromEnd, generateRecursive); }
From source file:hr.fer.zemris.vhdllab.util.BeanUtil.java
public static String beanName(Class<?> clazz) { Validate.notNull(clazz, "Bean class can't be null"); return StringUtils.uncapitalize(clazz.getSimpleName()); }