List of usage examples for org.apache.commons.lang Validate isTrue
public static void isTrue(boolean expression, String message)
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), "The value must be greater than zero"); Validate.isTrue( myObject.isOk(), "The object is not OK");
For performance reasons, the message string should not involve a string append, instead use the #isTrue(boolean,String,Object) method.
From source file:com.opengamma.analytics.financial.model.option.pricing.fourier.GaussianCharacteristicExponent.java
/** * /*www .j ava2 s .c o m*/ * @param mu The mean of the Gaussian distribution * @param sigma The standard deviation of the Gaussian distribution, not negative or zero */ public GaussianCharacteristicExponent(final double mu, final double sigma) { Validate.isTrue(sigma > 0.0, "sigma > 0"); _mu = mu; _sigma = sigma; }
From source file:com.skelril.aurora.events.custom.item.SpecialAttackEvent.java
public SpecialAttackEvent(final Player owner, final SpecType context, final ItemStack weapon, final SpecialAttack spec) { super(owner); Validate.isTrue(owner.equals(spec.getOwner()), "The owner and the spec owner must match!"); this.weapon = weapon; this.context = context; this.spec = spec; }
From source file:fr.ritaly.dungeonmaster.actuator.SequentialActuator.java
public SequentialActuator(Actuator... actuators) { Validate.notNull(actuators, "The given array of actuators is null"); Validate.isTrue(actuators.length > 0, "The given array of actuators is empty"); this.actuators.addAll(Arrays.asList(actuators)); final StringBuilder builder = new StringBuilder(512); boolean first = true; for (Actuator actuator : actuators) { if (!first) { builder.append(","); } else {//from w w w . j a v a2 s. com first = false; } builder.append(actuator.getLabel()); } this.label = getClass().getSimpleName() + "[" + builder + "]"; }
From source file:com.hmsinc.epicenter.webapp.util.AntiSamyPolicyFactoryBean.java
public Object getObject() throws Exception { Validate.notNull(location, "Policy file location not specified."); Validate.isTrue(location.exists(), "Policy file " + location.toString() + " does not exist."); return Policy.getInstance(location.getFile()); }
From source file:it.gualtierotesta.gdocx.GFactory.java
/** * Build a CT border/*from w ww . jav a 2s .c o m*/ * * @param lSize width of the border in eighths of a point (min 2, max 96) * @param eBorderLine type of the border line (enum) * @param sColor color of the border line in RRGGBB format (es. FFFF00). It can be null if no border line * @param lSpace Specifies the spacing offset. Values are specified in points (1/72nd of an inch). it can be * null * @return same GTc instance */ public static CTBorder buildBorder(final long lSize, @Nonnull final STBorder eBorderLine, @CheckForNull final String sColor, @CheckForNull final Long lSpace) { Validate.isTrue(2L <= lSize && lSize <= 96, "Size value not valid"); Validate.notNull(eBorderLine, "Border Line not valid"); final CTBorder ctBorder = FACTORY.createCTBorder(); ctBorder.setVal(eBorderLine); if (STBorder.NIL != eBorderLine && STBorder.NONE != eBorderLine) { if (null != sColor) { ctBorder.setColor(sColor); } if (null != lSpace) { ctBorder.setSpace(BigInteger.valueOf(lSpace)); } ctBorder.setSz(BigInteger.valueOf(lSize)); } return ctBorder; }
From source file:me.ampayne2.ultimategames.api.games.blocks.GameBlock.java
/** * Creates a new GameBlock.//from w w w . ja v a 2 s . c o m * * @param item The ItemStack of the GameBlock. */ public GameBlock(ItemStack item, boolean canBeBroken) { Validate.notNull(item, "ItemStack cannot be null"); Validate.isTrue(item.getType().isBlock(), "ItemStack type must be a block"); this.item = item; this.canBeBroken = canBeBroken; }
From source file:com.opengamma.analytics.financial.equity.future.derivative.CashSettledFuture.java
/** * /*from ww w.j a v a 2 s . co m*/ * @param timeToExpiry time (in years as a double) until the date-time at which the reference index is fixed * @param timeToSettlement time (in years as a double) until the date-time at which the contract is settled * @param strike Set strike price at trade time. Note that we may handle margin by resetting this at the end of each trading day * @param currency The reporting currency of the future * @param unitAmount The unit value per tick, in given currency */ public CashSettledFuture(final double timeToExpiry, final double timeToSettlement, final double strike, final Currency currency, final double unitAmount) { Validate.isTrue(unitAmount > 0, "point value must be positive"); _timeToExpiry = timeToExpiry; _timeToSettlement = timeToSettlement; _referencePrice = strike; _unitAmount = unitAmount; _currency = currency; }
From source file:com.opengamma.analytics.financial.model.finitedifference.ExponentialMeshing.java
/** * creates a non-uniform set of points according to the formula $x_i = \theta + \eta*\exp(\lambda z_i)$, where the points run from * $x_0$ to $x_{N-1}$ (i.e. there are N points), $\eta = (x_{N-1} - x_0)/(\exp(\lambda) - 1)$ and $\theta = x_0 - \eta$. The points $z_i$ are uniform on (0,1) and * given by $z_i = i/(N-1)$. /*from ww w . ja v a 2 s . com*/ * @param lowerBound The value of $x_0$ * @param upperBound The value of $x_{N-1}$ * @param nPoints Number of Points (equal to N in the above formula) * @param lambda Bunching parameter. $\lambda = 0$ is uniform, $\lambda > 0$ gives a high density of points near $x_0$ and $\lambda < 0$ gives a high density * of points near $x_{N-1}$ */ public ExponentialMeshing(final double lowerBound, final double upperBound, final int nPoints, final double lambda) { super(nPoints); Validate.isTrue(upperBound > lowerBound, "need upperBound>lowerBound"); _l = lowerBound; _r = upperBound; _lambda = lambda; if (lambda == 0.0) { _linear = true; _theta = lowerBound; _eta = (upperBound - lowerBound); } else { _linear = false; _eta = (upperBound - lowerBound) / (Math.exp(lambda) - 1); _theta = lowerBound - _eta; } _um = new UniformMeshing(nPoints); _fpValues = null; }
From source file:com.opengamma.analytics.math.statistics.leastsquare.LeastSquareResults.java
public LeastSquareResults(final double chiSq, final DoubleMatrix1D parameters, final DoubleMatrix2D covariance, final DoubleMatrix2D inverseJacobian) { Validate.isTrue(chiSq >= 0, "chi square < 0"); Validate.notNull(parameters, "parameters"); Validate.notNull(covariance, "covariance"); final int n = parameters.getNumberOfElements(); Validate.isTrue(covariance.getNumberOfColumns() == n, "covariance matrix not square"); Validate.isTrue(covariance.getNumberOfRows() == n, "covariance matrix wrong size"); //TODO test size of inverse Jacobian _chiSq = chiSq;//from www . j a v a 2 s. c om _parameters = parameters; _covariance = covariance; _inverseJacobian = inverseJacobian; }
From source file:ar.com.zauber.labs.kraken.providers.wikipedia.model.impl.SimpleWikiPage.java
/** Creates the SimpleWikiPage. */ public SimpleWikiPage(final long pageId, final Language lang, final Set<String> titles, final Map<Language, WikiPage> langTitles) { Validate.notNull(lang, "null language"); Validate.notNull(titles, "null titles"); Validate.isTrue(titles.size() > 0, "wiki page must have at least one title"); for (final String title : titles) { Validate.isTrue(StringUtils.isNotBlank(title), "invalid title"); }//from ww w . j a v a 2s . c o m for (final Map.Entry<Language, WikiPage> langTitle : langTitles.entrySet()) { Validate.notNull(langTitle.getKey()); Validate.notNull(langTitle.getValue()); } this.pageId = pageId; this.lang = lang; this.titles = Collections.unmodifiableSet(titles); this.langTitles = Collections.unmodifiableMap(langTitles); }