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:net.hamnaberg.rest.ResourceHandle.java
ResourceHandle(final URI uri, final Option<Tag> tag) { Validate.notNull(uri, "URI may not be null"); Validate.notNull(tag, "Tag may not be null"); this.uri = uri; this.tag = tag; }
From source file:fr.ribesg.bukkit.api.chat.Hover.java
/** * Builds a new Hover of type {@link Type#SHOW_ITEM}. * * @param item the ItemStack//w w w .ja v a 2s . c o m * * @return a new Hover of type SHOW_ITEM */ public static Hover of(final ItemStack item) { Validate.notNull(item, "item can't be null"); return new Hover(Type.SHOW_ITEM, item.clone()); }
From source file:io.cloudslang.lang.cli.utils.MetadataHelperImpl.java
@Override public String extractMetadata(File file) { Validate.notNull(file, "File can not be null"); Validate.notNull(file.getAbsolutePath(), "File path can not be null"); Validate.isTrue(file.isFile(), "File: " + file.getName() + " was not found"); Metadata metadata = slang.extractMetadata(SlangSource.fromFile(file)); return prettyPrint(metadata); }
From source file:net.daboross.bukkitdev.skywars.events.events.PlayerRespawnAfterGameEndInfo.java
public PlayerRespawnAfterGameEndInfo(final Player player, final boolean ensureAllIsSync) { this.ensureAllIsSync = ensureAllIsSync; Validate.notNull(player, "Player cannot be null"); this.player = player; }
From source file:com.opengamma.analytics.math.curve.DivideCurveSpreadFunction.java
/** * @param curves An array of curves, not null or empty * @return A function that will find the value of each curve at the given input <i>x</i> and divide each in turn *///w w w . java 2s . co m @SuppressWarnings("unchecked") @Override public Function<Double, Double> evaluate(final Curve<Double, Double>... curves) { Validate.notNull(curves, "x"); Validate.notEmpty(curves, "curves"); return new Function<Double, Double>() { @Override public Double evaluate(final Double... x) { Validate.notNull(x, "x"); Validate.notEmpty(x, "x"); final double x0 = x[0]; double y = curves[0].getYValue(x0); for (int i = 1; i < curves.length; i++) { y /= curves[i].getYValue(x0); } return y; } }; }
From source file:net.hamnaberg.rest.DefaultResource.java
private DefaultResource(ResourceHandle handle, Headers headers, R data) { Validate.notNull(handle, "Resource Handle may not be null"); Validate.notNull(headers, "Headers may not be null"); this.headers = headers; this.handle = handle; this.data = data; }
From source file:com.github.fritaly.dualcommander.FileComparator.java
public FileComparator(HasParentDirectory delegate) { Validate.notNull(delegate, "The given delegate is null"); this.delegate = delegate; }
From source file:com.opengamma.analytics.financial.model.option.definition.PDEOptionDataBundle.java
public PDEOptionDataBundle(final Surface<Double, Double, Double> a, final Surface<Double, Double, Double> b, final Surface<Double, Double, Double> c, final double spot, final ZonedDateTime date) { super(null, 0.0, null, spot, date); Validate.notNull(a, "null a"); Validate.notNull(b, "null b"); Validate.notNull(c, "null c"); _a = a;//from w w w . j a v a 2s .c om _b = b; _c = c; }
From source file:com.opengamma.analytics.financial.model.option.pricing.analytic.ForwardStartOptionModel.java
@Override public Function1D<StandardOptionDataBundle, Double> getPricingFunction( final ForwardStartOptionDefinition definition) { Validate.notNull(definition, "definition"); return new Function1D<StandardOptionDataBundle, Double>() { @SuppressWarnings("synthetic-access") @Override/*from www. ja v a2s . c o m*/ public Double evaluate(final StandardOptionDataBundle data) { Validate.notNull(data, "data"); final ZonedDateTime date = data.getDate(); final double s = data.getSpot(); final double t = definition.getTimeToExpiry(date); final double start = definition.getTimeToStart(date); final double b = data.getCostOfCarry(); final double r = data.getInterestRate(t); // does this need r at both times? final double alpha = definition.getAlpha(); final double sigma = data.getVolatility(t, alpha * s); final double deltaT = t - start; final double df1 = Math.exp(start * (b - r)); final double df2 = Math.exp(deltaT * (b - r)); final double df3 = Math.exp(-r * deltaT); final double sigmaT = sigma * Math.sqrt(deltaT); final double d1 = (Math.log(1. / alpha) + deltaT * (b + 0.5 * sigma * sigma)) / sigmaT; final double d2 = d1 - sigmaT; final int sign = definition.isCall() ? 1 : -1; return s * df1 * (sign * (df2 * NORMAL.getCDF(sign * d1) - alpha * df3 * NORMAL.getCDF(sign * d2))); } }; }
From source file:com.opengamma.analytics.math.linearalgebra.CholeskyDecompositionCommonsResult.java
/** * Constructor./*from w w w. java2 s.c o m*/ * @param ch The result of the Cholesky decomposition. */ public CholeskyDecompositionCommonsResult(final CholeskyDecomposition ch) { Validate.notNull(ch, "Cholesky decomposition"); _determinant = ch.getDeterminant(); _l = CommonsMathWrapper.unwrap(ch.getL()); _lt = CommonsMathWrapper.unwrap(ch.getLT()); _solver = ch.getSolver(); }