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.opengamma.analytics.financial.covariance.HistoricalVolatilityCalculator.java
protected void testTimeSeries(final DoubleTimeSeries<?>[] tsArray, final int minLength) { Validate.notNull(tsArray, "array of time series"); Validate.notEmpty(tsArray, "array of time series"); testNotNullOrEmpty(tsArray[0]);/* ww w. java 2s . c o m*/ final DoubleTimeSeries<?> ts = tsArray[0]; testTimeSeriesSize(ts, minLength); for (int i = 1; i < tsArray.length; i++) { testTimeSeriesSize(tsArray[i], minLength); testTimeSeriesDates(ts, tsArray[i]); } }
From source file:com.keetip.versio.service.impl.VersioningServiceImpl.java
public <T extends Resource> Optional<T> getRevision(String projectName, String resourceName, Class<T> resourceClass, Integer revision) { Validate.notEmpty(projectName, "Project name is required"); Validate.notEmpty(resourceName, "Resource name is required"); //TODO1: resolve projectId from projectName UUID projectId = UUID.randomUUID(); Optional<ResourceKey> key = resolveKey(projectId, resourceName); Optional<Resource> resourceHolder = null; if (!key.isPresent()) { Collection<Resource> allRevisions = mResourceProvider.getRevisions(projectId, resourceName); } else {/* w w w .j a v a 2s . co m*/ } if (!key.isPresent()) { resourceHolder = tryLoadResource(key.get(), projectId, resourceName); } else { resourceHolder = getLatestRevision(mResources.get(key.get())); } if (resourceHolder.isPresent()) { Object resource = resourceHolder.get(); return Optional.of(resourceClass.cast(resource)); } return Optional.absent(); }
From source file:com.mxhero.plugin.cloudstorage.onedrive.api.RedeemDaemonRequest.java
/** * Validate./*from ww w .ja v a2 s . com*/ */ public void validate() { Validate.notEmpty(clientId, "clientId field must be provided"); Validate.notEmpty(tenantId, "tenantId field must be provided"); Validate.notEmpty(resourceSharepointId, "resourceSharepointId field must be provided"); }
From source file:com.aeells.hibernate.service.HibernateServiceImpl.java
public final T findById(final Class daoClass, final String id) { Validate.notNull(daoClass, "class cannot be null!"); Validate.notEmpty(id, "id cannot be empty!"); //noinspection unchecked return (T) hibernateTemplate.get(daoClass, id); }
From source file:io.cloudslang.lang.tools.build.verifier.SlangContentVerifier.java
public PreCompileResult createModelsAndValidate(String directoryPath, boolean shouldValidateDescription, boolean shouldValidateCheckstyle) { Validate.notEmpty(directoryPath, "You must specify a path"); Validate.isTrue(new File(directoryPath).isDirectory(), "Directory path argument \'" + directoryPath + "\' does not lead to a directory"); Map<String, Executable> slangModels = new HashMap<>(); Collection<File> slangFiles = slangCompilationService.listSlangFiles(new File(directoryPath), true); loggingService.logEvent(Level.INFO, "Start compiling all slang files under: " + directoryPath); loggingService.logEvent(Level.INFO, slangFiles.size() + " .sl files were found"); loggingService.logEvent(Level.INFO, ""); Queue<RuntimeException> exceptions = new ArrayDeque<>(); String errorMessagePrefixMetadata = ""; for (File slangFile : slangFiles) { Executable sourceModel = null; try {/*from w ww . ja v a2 s . c om*/ errorMessagePrefixMetadata = "Failed to extract metadata for file: \'" + slangFile.getAbsoluteFile() + "\'.\n"; String errorMessagePrefixCompilation = "Failed to compile file: \'" + slangFile.getAbsoluteFile() + "\'.\n"; Validate.isTrue(slangFile.isFile(), "file path \'" + slangFile.getAbsolutePath() + "\' must lead to a file"); SlangSource slangSource = SlangSource.fromFile(slangFile); ExecutableModellingResult preCompileResult = slangCompiler.preCompileSource(slangSource); sourceModel = preCompileResult.getExecutable(); exceptions.addAll(prependPrefix(preCompileResult.getErrors(), errorMessagePrefixCompilation)); MetadataModellingResult metadataResult = metadataExtractor .extractMetadataModellingResult(slangSource, shouldValidateCheckstyle); Metadata sourceMetadata = metadataResult.getMetadata(); exceptions.addAll(prependPrefix(metadataResult.getErrors(), errorMessagePrefixMetadata)); if (sourceModel != null) { int size = exceptions.size(); staticValidator.validateSlangFile(slangFile, sourceModel, sourceMetadata, shouldValidateDescription, exceptions); if (size == exceptions.size()) { slangModels.put(getUniqueName(sourceModel), sourceModel); } } } catch (Exception e) { String errorMessage = errorMessagePrefixMetadata + e.getMessage(); loggingService.logEvent(Level.ERROR, errorMessage); exceptions.add(new RuntimeException(errorMessage, e)); if (e instanceof MetadataMissingException && sourceModel != null) { slangModels.put(getUniqueName(sourceModel), sourceModel); } } } if (slangFiles.size() != slangModels.size()) { exceptions.add(new RuntimeException("Some Slang files were not pre-compiled.\nFound: " + slangFiles.size() + " executable files in path: \'" + directoryPath + "\' But managed to create slang models for only: " + slangModels.size())); } PreCompileResult preCompileResult = new PreCompileResult(); preCompileResult.addExceptions(exceptions); preCompileResult.addResults(slangModels); return preCompileResult; }
From source file:edu.snu.leader.hierarchy.simple.SimpleDistanceUpdateStrategy.java
/** * Initializes this update strategy/* w w w.java 2s .com*/ * * @param simState The simulation state * @see edu.snu.leader.hierarchy.simple.UpdateStrategy#initialize(edu.snu.leader.hierarchy.simple.SimulationState) */ @Override public void initialize(SimulationState simState) { _LOG.trace("Entering initialize( simState )"); // Get the simulation properties Properties props = simState.getProps(); // Get the motivation increase due to time String motivationTimeIncrease = props.getProperty(_MOTIVATION_TIME_INCREASE_KEY); Validate.notEmpty(motivationTimeIncrease, "Motivation increase due to time is required (key=" + _MOTIVATION_TIME_INCREASE_KEY + ")"); _motivationTimeIncrease = Float.parseFloat(motivationTimeIncrease); // Get the motivation increase due to neighbor activity String motivationNeighborIncrease = props.getProperty(_MOTIVATION_NEIGHBOR_INCREASE_KEY); Validate.notEmpty(motivationNeighborIncrease, "Motivation increase due to activity of a neighbor is required (key=" + _MOTIVATION_NEIGHBOR_INCREASE_KEY + ")"); _motivationNeighborIncrease = Float.parseFloat(motivationNeighborIncrease); // Log the values _LOG.debug("_motivationTimeIncrease=[" + _motivationTimeIncrease + "] _motivationNeighborIncrease=[" + _motivationNeighborIncrease + "]"); _LOG.trace("Leaving initialize( simState )"); }
From source file:com.edmunds.etm.loadbalancer.api.VirtualServer.java
public VirtualServer(String name, HostAddress hostAddress, Set<PoolMember> poolMembers) { Validate.notEmpty(name, "Name is empty"); this.name = name; this.hostAddress = hostAddress; this.poolMembers = poolMembers != null ? poolMembers : new HashSet<PoolMember>(); }
From source file:ch.algotrader.dao.security.SecurityDaoImpl.java
@Override public Security findByIsin(String isin) { Validate.notEmpty(isin, "isin is empty"); return findUniqueCaching("Security.findByIsin", QueryType.BY_NAME, new NamedParam("isin", isin)); }
From source file:com.fusesource.examples.horo.model.StarSign.java
private StarSign(String signName, Integer startMonth, Integer startDay, Integer endMonth, Integer endDay) { Validate.notEmpty(signName, "signName is empty"); Validate.notNull(startMonth, "startMonth is null"); Validate.notNull(startDay, "startDay is null"); Validate.notNull(endMonth, "endMonth is null"); Validate.notNull(endDay, "endDay is null"); this.name = signName; // year is intended to be ignored this.start = new MonthDay(startMonth, startDay); this.end = new MonthDay(endMonth, endDay); }
From source file:ch.algotrader.esper.EngineManagerImpl.java
@Override public boolean hasEngine(final String engineName) { Validate.notEmpty(engineName, "Engine name is empty"); return this.engineMap.containsKey(engineName); }