List of usage examples for org.apache.commons.lang Validate notEmpty
public static void notEmpty(String string, String message)
Validate an argument, throwing IllegalArgumentException
if the argument String is empty (null
or zero length).
Validate.notEmpty(myString, "The string must not be empty");
From source file:com.fusesource.test.http.ResourceHttpHandler.java
public ResourceHttpHandler(Class testClass, String resource) { Validate.notNull(testClass, "testClass is null"); Validate.notEmpty(resource, "resource is empty"); try {//w ww. j a v a 2 s. c om response = new ResourceHelper(testClass).getResourceAsString(resource).getBytes(); } catch (IOException e) { throw new IllegalArgumentException(e); } }
From source file:com.fusesource.test.ResourceHelper.java
public String getResourceAsString(String fileName) throws IOException { Validate.notEmpty(fileName, "fileName is empty"); InputStream inputStream = testClass.getResourceAsStream(fileName); if (inputStream == null) { throw new RuntimeException("Could not find " + fileName); }/* w w w . j ava2s. c o m*/ BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream)); StringBuilder out = new StringBuilder(); while (true) { String line = bufferedReader.readLine(); if (line == null) { break; } else { out.append(line + SystemUtils.LINE_SEPARATOR); } } return out.toString(); }
From source file:io.dfox.junit.http.api.BaseResult.java
/** * @param grouping The group the test belongs to. For JUnit tests, this is the test class name. * @param name The name of the test. For JUnit tests, this is the test method name. */// w ww. ja v a 2 s . c o m public BaseResult(final String grouping, final String name) { Validate.notEmpty(grouping, "grouping cannot be empty"); Validate.notEmpty(name, "name cannot be empty"); this.grouping = grouping; this.name = name; }
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 *///from w w w. j a v a 2 s .com @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:bigbluej.ModuleCommand.java
private ModuleCommand(String name, List<DocumentCommand> documents) { Validate.notEmpty(name, "name"); this.name = name; this.documents = documents; }
From source file:com.opengamma.analytics.math.curve.MultiplyCurveSpreadFunction.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 multiply each in turn */// w w w . ja va 2s .com @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:com.edmunds.etm.common.api.UrlToken.java
public UrlToken(String name, List<String> values) { Validate.notEmpty(name, "UrlToken name is empty"); this.name = name; this.values = values == null ? new ArrayList<String>() : values; }
From source file:com.vmware.identity.idm.AlternativeOCSPList.java
public AlternativeOCSPList(String siteID, List<AlternativeOCSP> ocspList) { Validate.notEmpty(siteID, "siteID"); this._siteID = siteID; this.set_ocspList(ocspList); }
From source file:io.dfox.junit.http.api.Error.java
/** * @param name The name of the error. For JUnit tests, this is the exception name. * @param message The optional exception message. For JUnit tests, this is the exception * message./*from ww w . j a v a 2s. c o m*/ */ public Error(final String name, final Optional<String> message) { Validate.notEmpty(name, "name cannot be empty"); Validate.notNull(message, "message cannot be null"); this.name = name; this.message = message; }
From source file:com.opengamma.analytics.financial.riskfactor.GreekDataBundle.java
public GreekDataBundle(final GreekResultCollection greekValues, final Map<UnderlyingType, Double> underlyingData, final OptionTradeData tradeData) { Validate.notNull(greekValues, "greek result collection"); if (greekValues.isEmpty()) { throw new IllegalArgumentException("Greek result collection was empty"); }// ww w. jav a2 s . c o m Validate.notNull(underlyingData, "underlying data"); Validate.notEmpty(underlyingData, "underlying data"); Validate.notNull(tradeData, "trade data"); _greekValues = greekValues; _underlyingData = underlyingData; _tradeData = tradeData; }