List of usage examples for org.apache.commons.lang Validate noNullElements
public static void noNullElements(Collection collection, String message)
Validate an argument, throwing IllegalArgumentException
if the argument Collection has null
elements or is null
.
Validate.noNullElements(myCollection, "The collection must not contain null elements");
If the collection is null then the message in the exception is 'The validated object is null'.
From source file:org.codice.solr.factory.impl.EmbeddedSolrFiles.java
/** * Constructor.//from www. ja va 2 s . co m * * @param coreName name of the Solr core * @param configXml name of the Solr configuration file * @param schemaXmls file names of the Solr core schemas to attempt to load (will start with the * first and fallback to the others in order if unavailable) * @param configProxy {@link ConfigurationFileProxy} instance to use * @throws IllegalArgumentException if <code>coreName</code>, <code>configXml</code>, <code> * schemaXmls</code>, or <code>configProxy</code> is <code>null</code> or if unable to find * any files */ public EmbeddedSolrFiles(String coreName, String configXml, String[] schemaXmls, ConfigurationFileProxy configProxy) { Validate.notNull(coreName, "invalid null Solr core name"); Validate.notNull(configXml, "invalid null Solr config file"); Validate.notNull(schemaXmls, "invalid null Solr schema files"); Validate.notEmpty(schemaXmls, "missing Solr schema files"); Validate.noNullElements(schemaXmls, "invalid null Solr schema file"); Validate.notNull(configProxy, "invalid null Solr config proxy"); this.coreName = coreName; this.configName = configXml; this.configProxy = configProxy; this.configFile = FileUtils.toFile(configProxy.getResource(configXml, coreName)); Validate.notNull(configFile, "Unable to find Solr configuration file: " + configXml); File solrSchemaFile = null; String schemaXml = null; for (final String s : schemaXmls) { schemaXml = s; solrSchemaFile = FileUtils.toFile(configProxy.getResource(schemaXml, coreName)); if (solrSchemaFile != null) { break; } } Validate.notNull(solrSchemaFile, "Unable to find Solr schema file(s): " + Arrays.toString(schemaXmls)); this.schemaFile = solrSchemaFile; this.schemaName = schemaXml; }
From source file:org.eclipse.jubula.client.ui.rcp.utils.PersistenceObjectComparator.java
/** * {@inheritDoc}/*w w w . j a v a 2 s. co m*/ */ public int compare(IPersistentObject o1, IPersistentObject o2) { Validate.noNullElements(new Object[] { o1, o2 }, "The persistant objects must be not null!"); //$NON-NLS-1$ String pers1 = o1.getName().toLowerCase(); String pers2 = o2.getName().toLowerCase(); if (pers1 == null && pers2 == null) { return 0; } else if (pers2 == null) { return -1; } else if (pers1 == null) { return 1; } return pers1.compareTo(pers2); }
From source file:org.eclipse.jubula.rc.common.components.FindComponentBP.java
/** * Searchs for the component in the AUT with the given * <code>componentIdentifier</code>. * /* w w w. j a va2 s. c om*/ * @param componentIdentifier the identifier created in object mapping mode * @param hierarchy the current aut hierarchy * @throws IllegalArgumentException if the given identifer is null or <br> * the hierarchy is not valid: empty or containing null elements * @return the instance of the component of the AUT */ protected Object findComponent(final IComponentIdentifier componentIdentifier, final AUTHierarchy hierarchy) throws IllegalArgumentException { m_hierarchy = hierarchy; setProfile(AUTServerConfiguration.getInstance().getProfile()); // Fuzzy logic parameter List hierarchyNames = null; // parameter check Validate.notNull(componentIdentifier, "The component identifier must not be null."); //$NON-NLS-1$ hierarchyNames = componentIdentifier.getHierarchyNames(); Validate.noNullElements(hierarchyNames, "The component identifier contains no hierarchy information."); //$NON-NLS-1$ Iterator allComponents = new ArrayList(m_hierarchy.getHierarchyMap().values()).iterator(); HierarchyContainer bestMatch = null; double bestMatchPercentage = 0; double equivalence = 0; String suppClassName = componentIdentifier.getSupportedClassName(); final AUTServerConfiguration autServerConf = AUTServerConfiguration.getInstance(); int numberOfOtherMatchingComponents = 0; while (allComponents.hasNext()) { HierarchyContainer current = (HierarchyContainer) allComponents.next(); Object currComp = current.getCompID().getComp(); // check class compatibility first if (isAvailable(currComp) && isSupportedComponent(currComp) && ((suppClassName != null && (checkTestableClass(autServerConf, suppClassName, currComp))) || componentIdentifier.getComponentName().equals(getCompName(currComp)))) { equivalence = computeEquivalence(componentIdentifier, current); if (meetsThreshold(equivalence)) { numberOfOtherMatchingComponents++; } if (equivalence > bestMatchPercentage) { bestMatch = current; bestMatchPercentage = equivalence; } } } Object technicalComponent = null; if (bestMatch != null && meetsThreshold(bestMatchPercentage)) { technicalComponent = bestMatch.getCompID().getComp(); } componentIdentifier.setMatchPercentage(bestMatchPercentage); componentIdentifier.setNumberOfOtherMatchingComponents(numberOfOtherMatchingComponents); return technicalComponent; }
From source file:org.grouter.core.util.SchedulerService.java
/** * Consturctor/*from ww w. j a va 2 s. c o m*/ */ public SchedulerService(Set<Node> nodes) { Validate.noNullElements(nodes, "Can not handle null nodes!!"); this.nodes = nodes; for (Node node : nodes) { node.setNodeStatus(NodeStatus.NOTSTARTED); } try { scheduler = StdSchedulerFactory.getDefaultScheduler(); } catch (SchedulerException e) { logger.error("Could not create scheduler frm SchedulerFactory", e); throw new RuntimeException("Could not create scheduler from SchedulerFactory", e); } }
From source file:org.nebularis.defproxy.introspection.MethodSignature.java
public MethodSignature(final Class<?> returnType, final String name, final Class<?>... parameterTypes) { Validate.notNull(returnType, "return type cannot be null"); Validate.notEmpty(name, "method name cannot be null"); Validate.noNullElements(parameterTypes, "parameter types cannot contain null elements"); this.returnType = returnType; this.name = name; this.parameterTypes = parameterTypes; }
From source file:org.openscore.lang.compiler.scorecompiler.ScoreCompilerImpl.java
@Override public CompilationArtifact compile(Executable executable, Set<Executable> path) { Map<String, Executable> filteredDependencies = new HashMap<>(); //we handle dependencies only if the file has imports boolean hasDependencies = CollectionUtils.isNotEmpty(executable.getDependencies()) && executable.getType().equals(SlangTextualKeys.FLOW_TYPE); if (hasDependencies) { Validate.notEmpty(path,// ww w . j a v a 2 s . co m "Source " + executable.getName() + " has dependencies but no path was given to the compiler"); Validate.noNullElements(path, "Source " + executable.getName() + " has empty dependencies"); //we add the current executable since a dependency can require it List<Executable> availableExecutables = new ArrayList<>(path); availableExecutables.add(executable); //than we match the references to the actual dependencies filteredDependencies = dependenciesHelper.matchReferences(executable, availableExecutables); // Validate that all the tasks of a flow have navigations for all the reference's results validateAllDependenciesResultsHaveMatchingNavigations(executable, filteredDependencies); } //next we create an execution plan for the required executable ExecutionPlan executionPlan = compileToExecutionPlan(executable); //and also create execution plans for all other dependencies Map<String, ExecutionPlan> dependencies = convertMap(filteredDependencies, new Converter<Executable, ExecutionPlan>() { @Override public ExecutionPlan convert(Executable compiledExecutable) { return compileToExecutionPlan(compiledExecutable); } }); Collection<Executable> executables = new ArrayList<>(filteredDependencies.values()); executables.add(executable); executionPlan.setSubflowsUUIDs(new HashSet<>(dependencies.keySet())); return new CompilationArtifact(executionPlan, dependencies, executable.getInputs(), getSystemProperties(executables)); }
From source file:org.openscore.lang.compiler.SlangCompilerImpl.java
@Override public CompilationArtifact compile(SlangSource source, String operationName, Set<SlangSource> path) { Executable executable = transformToExecutable(source, operationName); Map<String, Executable> filteredDependencies = new HashMap<>(); //we handle dependencies only if the file has imports boolean hasDependencies = MapUtils.isNotEmpty(executable.getDependencies()) && executable.getType().equals(SlangTextualKeys.FLOW_TYPE); if (hasDependencies) { Validate.notEmpty(path,//from ww w . j a v a 2 s . co m "Source " + source.getName() + " has dependencies but no path was given to the compiler"); Validate.noNullElements(path, "Source " + source.getName() + " has empty dependencies"); //we transform also all of the files in the given path to model objects Map<String, Executable> pathExecutables = transformDependencies(path); //we add the current executable since a dependency can require it List<Executable> availableExecutables = new ArrayList<>(pathExecutables.values()); availableExecutables.add(executable); //than we match the references to the actual dependencies filteredDependencies = dependenciesHelper.matchReferences(executable, availableExecutables); } //next we create an execution plan for the required executable ExecutionPlan executionPlan = compileToExecutionPlan(executable); //and also create execution plans for all other dependencies Map<String, ExecutionPlan> dependencies = convertMap(filteredDependencies, new Converter<Executable, ExecutionPlan>() { @Override public ExecutionPlan convert(Executable compiledExecutable) { return compileToExecutionPlan(compiledExecutable); } }); return new CompilationArtifact(executionPlan, dependencies, executable.getInputs()); }
From source file:org.sglj.service.rmi.AbstractRemoteServiceManager.java
/** * /* w w w .ja v a2s. c o m*/ * @param remoteServices services to be registered * @throws IllegalArgumentException if the contract defined in * the {@link RemoteServiceManager} interface is broken. */ public <T2 extends T> AbstractRemoteServiceManager(T2... remoteServices) throws IllegalArgumentException { Validate.noNullElements(remoteServices, "Remote service cannot be null"); Set<T> uniqueServices = new HashSet<T>(remoteServices.length); for (T remoteService : remoteServices) { uniqueServices.add(remoteService); } // ensure that there are no duplicate services Validate.isTrue(uniqueServices.size() == remoteServices.length, "Duplicate services detected"); // ensure that services have distinct identifiers Set<Byte> ids = new HashSet<Byte>(uniqueServices.size()); for (RemoteService service : remoteServices) { ids.add(service.getId()); } Validate.isTrue(uniqueServices.size() == ids.size(), "Services with identical id detected"); ids.clear(); // free memory before allocating new services = Collections.unmodifiableList(new ArrayList<T>(uniqueServices)); // retrieve all remote methods and store them in a map by name for (RemoteService service : services) { Method[] methods = service.getClass().getMethods(); Set<Pair<String, Integer>> set = new HashSet<Pair<String, Integer>>(); for (Method m : methods) { if (m.isAnnotationPresent(RemoteMethod.class)) { int paramCount = m.getParameterTypes().length; if (!set.add(new Pair<String, Integer>(m.getName(), paramCount))) { throw new IllegalArgumentException("Two methods with the same name \"" + m.getName() + "\" and with " + paramCount + " parameters detected in service" + service); } registerRemoteMethod(service.getId(), m); } } } }
From source file:org.xcmis.search.model.operand.DynamicOperand.java
/** * Create a arithmetic dynamic operand that operates upon the supplied * selector name(s).//from www. j ava 2s . c o m * * @param selectorNames * the selector names */ protected DynamicOperand(Collection<SelectorName> selectorNames) { Validate.noNullElements(selectorNames, "The selectorNames argument may not be null"); this.selectorNames = Collections.unmodifiableSet(new LinkedHashSet<SelectorName>(selectorNames)); this.hcode = new HashCodeBuilder().append(selectorNames).toHashCode(); }
From source file:org.xcmis.search.model.operand.DynamicOperand.java
/** * Create a arithmetic dynamic operand that operates upon the selector names * given by the supplied dynamic operand(s). * /* ww w . jav a 2 s . c o m*/ * @param operands * the operands defining the selector names */ protected DynamicOperand(DynamicOperand... operands) { Validate.noNullElements(operands, "The operands argument may not be null"); Set<SelectorName> names = new LinkedHashSet<SelectorName>(); for (DynamicOperand operand : operands) { names.addAll(operand.getSelectorNames()); } this.selectorNames = Collections.unmodifiableSet(names); this.hcode = new HashCodeBuilder().append(selectorNames).toHashCode(); }