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:edu.snu.leader.discrete.simulator.SueurPersonalityDecisionCalculator.java
@Override public void initialize(SimulationState simState) { _simState = simState;//from ww w .j av a 2s. c o m // get values from properties String alpha = _simState.getProperties().getProperty("alpha"); Validate.notEmpty(alpha, "Alpha may not be empty"); _alpha = Double.parseDouble(alpha); String alphaC = _simState.getProperties().getProperty("alpha-c"); Validate.notEmpty(alphaC, "Alpha-c may not be empty"); _alphaC = Double.parseDouble(alphaC); String beta = _simState.getProperties().getProperty("beta"); Validate.notEmpty(beta, "Beta may not be empty"); _beta = Double.parseDouble(beta); String betaC = _simState.getProperties().getProperty("beta-c"); Validate.notEmpty(betaC, "Beta-c may not be empty"); _betaC = Double.parseDouble(betaC); String q = _simState.getProperties().getProperty("q"); Validate.notEmpty(q, "q may not be empty"); _q = Double.parseDouble(q); String S = _simState.getProperties().getProperty("S"); Validate.notEmpty(S, "S may not be empty"); _S = Integer.parseInt(S); String cancellationThreshold = _simState.getProperties().getProperty("cancellation-threshold"); Validate.notEmpty(cancellationThreshold, "Use cancellation threshold may not be empty"); // add sueur info to root directory path _simState.setRootDirectory(Reporter.ROOT_DIRECTORY + "q=" + _q + "_" + "S=" + _S); }
From source file:com.dsh105.commodus.config.Options.java
public <T> void lockValue(Option<T> option, T value, Object... condition) { Validate.notEmpty(condition, "Condition cannot be empty!"); LOCKED.put(option, value);/*from w ww. java 2 s .c om*/ LOCKED_CONDITION.put(option, condition); }
From source file:net.jadler.KeyValues.java
/** * Adds new key-value pair. Supports multi-values for one key (if there has already been added * some value with this key, additional value is added instead of rewriting). Please note this method * creates new instance containing all existing values plus the new one rather than modifying this instance. * @param key key (cannot be empty)//from www . ja va 2 s .c o m * @param value value (cannot be {@code null}, however can be empty for valueless headers) * @return an exact copy of this instance containing all existing values plus the new one */ @SuppressWarnings("unchecked") public KeyValues add(final String key, final String value) { Validate.notEmpty(key, "key cannot be empty"); Validate.notNull(value, "value cannot be null, use an empty string instead"); final KeyValues res = new KeyValues(); res.values.putAll(this.values); res.values.put(key.toLowerCase(), value); return res; }
From source file:edu.snu.leader.discrete.simulator.SueurDefaultDecisionProbablityCalculator.java
@Override public void initialize(SimulationState simState) { _simState = simState;/*from w ww . j a va 2s. c o m*/ // set values from properties String alpha = _simState.getProperties().getProperty("alpha"); Validate.notEmpty(alpha, "Alpha may not be empty"); _alpha = Double.parseDouble(alpha); String alphaC = _simState.getProperties().getProperty("alpha-c"); Validate.notEmpty(alphaC, "Alpha-c may not be empty"); _alphaC = Double.parseDouble(alphaC); String beta = _simState.getProperties().getProperty("beta"); Validate.notEmpty(beta, "Beta may not be empty"); _beta = Double.parseDouble(beta); String betaC = _simState.getProperties().getProperty("beta-c"); Validate.notEmpty(betaC, "Beta-c may not be empty"); _betaC = Double.parseDouble(betaC); String q = _simState.getProperties().getProperty("q"); Validate.notEmpty(q, "q may not be empty"); _q = Double.parseDouble(q); String S = _simState.getProperties().getProperty("S"); Validate.notEmpty(S, "S may not be empty"); _S = Integer.parseInt(S); String cancellationThreshold = _simState.getProperties().getProperty("cancellation-threshold"); Validate.notEmpty(cancellationThreshold, "Use cancellation threshold may not be empty"); // add sueur info to root directory path _simState.setRootDirectory(Reporter.ROOT_DIRECTORY + "q=" + _q + "_" + "S=" + _S); }
From source file:com.opengamma.analytics.financial.model.option.pricing.montecarlo.MonteCarloOptionModel.java
@Override public GreekResultCollection getGreeks(final T definition, final U data, final Set<Greek> requiredGreeks) { Validate.notNull(definition, "definition"); Validate.notNull(data, "data"); Validate.notNull(requiredGreeks, "required greeks"); Validate.notEmpty(requiredGreeks, "required greeks"); if (requiredGreeks.contains(Greek.FAIR_PRICE)) { if (requiredGreeks.size() > 1) { s_logger.warn("Can only produce fair price"); }//w ww.j a v a2s . c om } else { throw new IllegalArgumentException("Can only produce fair price"); } final GreekResultCollection greeks = new GreekResultCollection(); final Function1D<U, Double> price = getPricingFunction(definition); greeks.put(Greek.FAIR_PRICE, price.evaluate(data)); return greeks; }
From source file:com.evolveum.midpoint.model.impl.filter.PatternFilter.java
@Override public <T extends Object> PrismPropertyValue<T> apply(PrismPropertyValue<T> propertyValue) { Validate.notNull(propertyValue, "Node must not be null."); String value = getStringValue(propertyValue); if (StringUtils.isEmpty(value)) { return propertyValue; }/*from w ww. ja va 2s .c om*/ Validate.notEmpty(getParameters(), "Parameters must not be null or empty."); List<Replace> replaces = getReplaces(); for (Replace replace : replaces) { Matcher matcher = replace.getPattern().matcher(value); value = matcher.replaceAll(replace.getReplacement()); } propertyValue.setValue((T) value); return propertyValue; }
From source file:edu.snu.leader.hierarchy.simple.HierarchyBuildingSimulation.java
/** * Initialize the simulation/*from ww w .jav a 2s .c o m*/ */ public void initialize() { _LOG.trace("Entering initialize()"); // Load the properties _props = MiscUtils.loadProperties(_PROPS_FILE_KEY); // Initialize the simulation state _simState.initialize(_props); // Load the reporter String reporter = _props.getProperty(_REPORTER_CLASS_KEY); Validate.notEmpty(reporter, "Reporter class (key=" + _REPORTER_CLASS_KEY + ") may not be empty"); _reporter = (Reporter) MiscUtils.loadAndInstantiate(reporter, "Reporter class"); _reporter.initialize(_simState); _LOG.trace("Leaving initialize()"); }
From source file:net.jadler.AbstractRequestMatching.java
/** * {@inheritDoc}/*from w w w .j a v a 2 s . c o m*/ */ @Override public T havingMethodEqualTo(final String method) { Validate.notEmpty(method, "method cannot be empty"); return havingMethod(equalToIgnoringCase(method)); }
From source file:edu.snu.leader.discrete.simulator.SueurSnxDefaultDecisionProbablityCalculator.java
@Override public void initialize(SimulationState simState) { // save the sim state for later _simState = simState;//from www . j a v a 2s .co m // parse some properties String alpha = _simState.getProperties().getProperty("alpha"); Validate.notEmpty(alpha, "Alpha may not be empty"); _alpha = Double.parseDouble(alpha); String alphaC = _simState.getProperties().getProperty("alpha-c"); Validate.notEmpty(alphaC, "Alpha-c may not be empty"); _alphaC = Double.parseDouble(alphaC); String beta = _simState.getProperties().getProperty("beta"); Validate.notEmpty(beta, "Beta may not be empty"); _beta = Double.parseDouble(beta); String betaC = _simState.getProperties().getProperty("beta-c"); Validate.notEmpty(betaC, "Beta-c may not be empty"); _betaC = Double.parseDouble(betaC); String q = _simState.getProperties().getProperty("q"); Validate.notEmpty(q, "q may not be empty"); _q = Double.parseDouble(q); String cancellationThreshold = _simState.getProperties().getProperty("cancellation-threshold"); Validate.notEmpty(cancellationThreshold, "Use cancellation threshold may not be empty"); // add sueur info to root directory path _simState.setRootDirectory(Reporter.ROOT_DIRECTORY + "q=" + _q + "_" + "S=N-x"); }
From source file:com.vmware.o11n.plugin.powershell.model.generate.ScriptActionGenerator.java
public ScriptModule generateAction(IVSOFactoryClient factory, String actionName, String categoryName, String script) {/*from ww w .ja va2 s . c o m*/ Validate.notNull(factory, "Factory can not be null."); Validate.notEmpty(actionName, "Action name can not be null or empty."); Validate.notEmpty(categoryName, "Category name can not be null or empty."); ScriptModule module = null; try { ScriptModuleCategory category = factory.getScriptModuleCategoryForName(categoryName); Validate.notNull(category, "Unable to find category with name " + categoryName); /*Check if there is already action with the same name*/ Validate.isTrue(category.getScriptModuleWithName(actionName) == null, "Action with provided name already exists."); ScriptModuleBuilder builder = new ScriptModuleBuilder().setName(actionName) .setDescription("Auto generated.").setResultType(Constants.TYPE_POWER_SHELL_REMOTE_PS_OBJECT); // Add input params // Add system input params builder.addParameter(PARAM_HOST, "PowerShell:PowerShellHost"); builder.addParameter(PARAM_SESSIONID, "string"); script = extractParameters(script, builder); builder.setScript(generateActionContent(script)); module = builder.insert(categoryName, factory); } catch (RuntimeException exc) { log.warn(exc.getMessage()); throw (RuntimeException) exc; } catch (Exception exc) { String message = exc.getMessage(); if (message == null || message.length() == 0) { message = "Failed to create action for provided script."; } log.warn(message); throw new RuntimeException(message, exc); } return module; }