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.Main.java
public static void main(String[] args) { System.setProperty("sim-properties", "cfg/sim/discrete/sim-properties.parameters"); _simulationProperties = MiscUtils.loadProperties("sim-properties"); String stringShouldRunGraphical = _simulationProperties.getProperty("run-graphical"); Validate.notEmpty(stringShouldRunGraphical, "Run graphical option required"); shouldRunGraphical = Boolean.parseBoolean(stringShouldRunGraphical); String stringTotalRuns = _simulationProperties.getProperty("run-count"); Validate.notEmpty(stringTotalRuns, "Run count required"); totalRuns = Integer.parseInt(stringTotalRuns); if (!shouldRunGraphical) { // run just text for (int run = 1; run <= totalRuns; run++) { System.out.println("Run " + run); System.out.println(); // create and initialize simulator Simulator simulator = new Simulator(run); _simulationProperties.put("current-run", String.valueOf(run)); simulator.initialize(_simulationProperties); // run it simulator.execute();//from w w w .j ava 2 s .c om } } else { // run graphical DebugLocationsStructure db = new DebugLocationsStructure("Conflict Simulation", 800, 600, 60); _simulationProperties.put("current-run", String.valueOf(1)); db.initialize(_simulationProperties, 1); db.run(); } }
From source file:com.training.utils.EmbeddedDataSourceFactory.java
public static JdbcDataSource getJdbcDataSource(String initScriptLocation) { Validate.notEmpty(initScriptLocation, "initScriptLocation is empty"); String mavenRelativePath = "src/main/resources/" + initScriptLocation; String mavenRootRelativePath = "camel-cookbook-transactions/" + mavenRelativePath; // check that we can load the init script FileLocator locator = new FileLocator().with(initScriptLocation).with(mavenRelativePath) .with(mavenRootRelativePath); File file = locator.find();/*from w w w. ja v a 2s . co m*/ Validate.notNull(file, locator.getErrorMessage()); FileSystemResource script = new FileSystemResource(file); JdbcDataSource dataSource = new JdbcDataSource(); dataSource.setURL("jdbc:h2:mem:db1;DB_CLOSE_DELAY=-1"); dataSource.setUser("sa"); dataSource.setPassword(""); DataSourceInitializer.initializeDataSource(dataSource, script); return dataSource; }
From source file:com.vmware.identity.idm.STSSpnValidator.java
public static boolean validate(String spn) { // validate spn format, and service principal name and domain name are // valid strings. Validate.notNull(spn, "Service Princiapal Name cannot be null"); Validate.notEmpty(spn, "Service Principal Name cannot be empty"); StringTokenizer st = new StringTokenizer(spn, VALID_SPN_SEPARATORS); if (st.countTokens() != 2) { logAndThrow("Invalid service principal name format: " + spn); } else {/*from w w w. j a va 2s . c om*/ String servicePrincipalName = st.nextToken(); String domainName = st.nextToken(); if (null == servicePrincipalName) { logAndThrow(String.format("Service Name must be specfied before [%s]" + VALID_SPN_SEPARATORS)); } if (!servicePrincipalName.equalsIgnoreCase(SERVICE_PRINCIPAL_NAME)) { logAndThrow("Service name must be STS (case insensitive)"); } if (null == domainName || domainName.trim().isEmpty()) { logAndThrow(String.format("Domain Name must be specfied after [%s]" + VALID_SPN_SEPARATORS)); } } return true; }
From source file:com.fusesource.examples.horo.model.StarSign.java
public static StarSign getInstance(String name) { Validate.notEmpty(name, "name is empty"); StarSign starSign = null;// ww w. j av a 2 s .c o m for (StarSign temp : values()) { if (temp.getName().toLowerCase().equals(name.toLowerCase())) { starSign = temp; break; } } if (starSign == null) { throw new IllegalStateException("Unable to find star sign for " + name); } return starSign; }
From source file:net.jadler.matchers.HeaderRequestMatcher.java
public HeaderRequestMatcher(final Matcher<? super List<String>> pred, final String headerName) { super(pred);/* w w w . j a v a2s. c o m*/ Validate.notEmpty(headerName, "headerName cannot be empty"); this.headerName = headerName; this.desc = "header " + headerName + " is"; }
From source file:net.jadler.matchers.ParameterRequestMatcher.java
public ParameterRequestMatcher(final Matcher<? super List<String>> pred, final String paramName) { super(pred);//from w w w . j ava2 s . c om Validate.notEmpty(paramName, "paramName cannot be empty"); this.paramName = paramName; this.desc = "parameter " + paramName + " is"; }
From source file:com.opengamma.analytics.math.interpolation.BasisFunctionAggregation.java
public BasisFunctionAggregation(List<Function1D<T, Double>> functions, double[] weights) { Validate.notEmpty(functions, "no functions"); Validate.notNull(weights, "no weights"); Validate.isTrue(functions.size() == weights.length); _f = functions;/*w w w.ja v a2 s . c om*/ _w = weights; }
From source file:com.opengamma.analytics.financial.covariance.VolatilityAnnualizingFunction.java
@Override public Double evaluate(final Double... x) { Validate.notNull(x, "x"); Validate.notEmpty(x, "x"); Validate.notNull(x[0], "x"); return Math.sqrt(_periodsPerYear / x[0]); }
From source file:com.opengamma.analytics.math.function.Function1D.java
/** * Implementation of the interface. This method only uses the first argument. * @param x The list of inputs into the function, not null and no null elements * @return The value of the function/* ww w .j a va 2 s.com*/ */ @Override public T evaluate(final S... x) { Validate.noNullElements(x, "Parameter list"); Validate.notEmpty(x, "parameter list"); if (x.length > 1) { throw new IllegalArgumentException("Array had more than one element"); } return evaluate(x[0]); }
From source file:me.pagekite.glen3b.library.bukkit.datastore.Message.java
/** * Search all {@link MessageProvider}s registered via the {@link org.bukkit.plugin.ServicesManager}, sorting by priority, to find the specified message. * @param key The key of the message to retrieve. * @return The color formatted message associated with the specified key, or {@code null} if not found. *///from www.j a v a 2 s. c om public static String get(String key) { Validate.notEmpty(key, "The key cannot be null or empty."); //Prioritized lists ArrayList<MessageProvider> highest = new ArrayList<MessageProvider>(); ArrayList<MessageProvider> high = new ArrayList<MessageProvider>(); ArrayList<MessageProvider> normal = new ArrayList<MessageProvider>(); ArrayList<MessageProvider> low = new ArrayList<MessageProvider>(); ArrayList<MessageProvider> lowest = new ArrayList<MessageProvider>(); populateLists(highest, high, normal, low, lowest); //Prioritized list results String highestMsg = getMessageFromList(highest, key); String highMsg = getMessageFromList(high, key); String normalMsg = getMessageFromList(normal, key); String lowMsg = getMessageFromList(low, key); String lowestMsg = getMessageFromList(lowest, key); //Check each list for a message if (highestMsg != null) return highestMsg; if (highMsg != null) return highMsg; if (normalMsg != null) return normalMsg; if (lowMsg != null) return lowMsg; //At this point we don't care if it's null return lowestMsg; }