List of usage examples for org.apache.commons.lang Validate isTrue
public static void isTrue(boolean expression)
Validate an argument, throwing IllegalArgumentException
if the test result is false
.
This is used when validating according to an arbitrary boolean expression, such as validating a primitive number or using your own custom validation expression.
Validate.isTrue( i > 0 ); Validate.isTrue( myObject.isOk() );
The message in the exception is 'The validated expression is false'.
From source file:net.daboross.bukkitdev.skywars.api.kits.SkyPotionData.java
private static SkyPotionData getDataModernApi(ItemStack item) { ItemMeta meta = item.getItemMeta();// www . jav a 2 s . c o m Validate.isTrue(meta instanceof PotionMeta); return new SkyPotionData(item.getType(), (PotionMeta) meta); }
From source file:com.training.utils.FileLocator.java
public FileLocator with(String location) { Validate.isTrue(!used); locations.add(location); return this; }
From source file:com.opengamma.analytics.math.integration.GaussHermiteWeightAndAbscissaFunction.java
@Override public GaussianQuadratureData generate(final int n) { Validate.isTrue(n > 0); final double[] x = new double[n]; final double[] w = new double[n]; final int m = (n + 1) / 2; final Pair<DoubleFunction1D, DoubleFunction1D>[] polynomials = HERMITE.getPolynomialsAndFirstDerivative(n); final Pair<DoubleFunction1D, DoubleFunction1D> pair = polynomials[n]; final DoubleFunction1D function = pair.getFirst(); final DoubleFunction1D derivative = pair.getSecond(); double root = 0; for (int i = 0; i < m; i++) { root = getInitialRootGuess(root, i, n, x); root = ROOT_FINDER.getRoot(function, derivative, root); final double dp = derivative.evaluate(root); x[i] = -root;// w ww .j a v a 2 s.com x[n - 1 - i] = root; w[i] = 2. / (dp * dp); w[n - 1 - i] = w[i]; } return new GaussianQuadratureData(x, w); }
From source file:ar.com.zauber.commons.spring.web.controllers.ExceptionController.java
/** Creates the ExceptionController.*/ public ExceptionController(final Map<Integer, String> map, final String defaultView) { Validate.notNull(map);//from www.j ava 2s . co m Validate.isTrue(StringUtils.isNotBlank(defaultView)); this.map = map; this.defaultView = defaultView; }
From source file:ar.com.zauber.commons.web.version.impl.PropertiesVersionProvider.java
/** * Creates the PropertiesVersionProvider. * * @param properties/*w w w . ja v a 2 s. com*/ * @param versionProperty */ public PropertiesVersionProvider(final Properties properties, final String versionProperty) { Validate.notNull(properties); Validate.isTrue(!StringUtils.isBlank(versionProperty)); version = properties.getProperty(versionProperty, ""); }
From source file:net.iglyduck.utils.sqlbuilder.WrapTable.java
public WrapTable(String table, String aliasName) { Validate.notEmpty(table);/*from w w w .j a va2 s .c o m*/ Validate.isTrue(!table.startsWith("(")); Validate.isTrue(!table.endsWith(")")); Validate.notEmpty(aliasName); this.table = table; this.aliasName = aliasName; }
From source file:com.edmunds.etm.management.util.VipDeltaCalculator.java
/** * Performs a delta operation on vips managed at the load balancer. * * @param loadBalancerVips the previous list of load balancer vips. * @param clientVips the current list of client vips. * @return the merged tree with flags to indicate where changes have been made *///www .ja v a 2 s . c om public ManagementVips deltaConnections(ManagementVips loadBalancerVips, ManagementVips clientVips) { Validate.notNull(loadBalancerVips, "loadBalancerVips is null."); Validate.isTrue(loadBalancerVips.getVipType() == COMPLETE); // Always copy the load balancer vips since they have the valid IP's return new VipDeltaLogic(loadBalancerVips, clientVips, false).delta(); }
From source file:com.opengamma.analytics.math.interpolation.MonotoneConvexSplineInterpolator1D.java
@Override public Double interpolate(final Interpolator1DDataBundle data, final Double value) { Validate.notNull(value, "value"); Validate.notNull(data, "data bundle"); Validate.isTrue(data instanceof Interpolator1DPiecewisePoynomialWithExtraKnotsDataBundle); final Interpolator1DPiecewisePoynomialWithExtraKnotsDataBundle polyData = (Interpolator1DPiecewisePoynomialWithExtraKnotsDataBundle) data; final DoubleMatrix1D res = FUNC.evaluate(polyData.getPiecewisePolynomialResult(), value); return res.getEntry(0); }
From source file:ar.com.zauber.commons.web.cache.impl.filter.actions.ChainedHttpCacheActions.java
/** * Creates the ChainedHttpCacheActions./* w w w. j av a 2 s . c o m*/ * * @param actions * chained actions */ public ChainedHttpCacheActions(final List<HttpCacheAction> actions) { Validate.notNull(actions); Validate.isTrue(actions.size() > 0); this.actions = actions; }
From source file:ar.com.zauber.garfio.services.impl.ClassicTimeConverter.java
/** @see TimeConverter#toHours(String)*/ public final String toHours(final String time) { Validate.isTrue(supportsTime(time)); Matcher m = timePattern.matcher(time); m.matches();//from w w w . jav a 2 s . c om StringBuilder builder = new StringBuilder(); if (m.group(1) != null) { builder.append(m.group(1)); } builder.append(m.group(2)); return builder.toString(); }