List of usage examples for org.springframework.util Assert notEmpty
public static void notEmpty(@Nullable Map<?, ?> map, Supplier<String> messageSupplier)
From source file:org.springframework.xd.extension.process.ShellCommandProcessor.java
/** * Creates a process to invoke a shell command to send and receive messages from the processes using the process's stdin and stdout. * * @param serializer an {@link org.springframework.integration.ip.tcp.serializer.AbstractByteArraySerializer} to delimit messages * @param command the shell command with command line arguments as separate strings *///from w w w.j ava 2s .c o m public ShellCommandProcessor(AbstractByteArraySerializer serializer, String command) { Assert.hasLength(command, "A shell command is required"); Assert.notNull(serializer, "'serializer' cannot be null"); this.command = command; List<String> commandPlusArgs = parse(command); Assert.notEmpty(commandPlusArgs, "The shell command is invalid: '" + command + "'"); this.serializer = serializer; processBuilder = new ProcessBuilder(commandPlusArgs); }
From source file:org.springframework.xd.jdbc.SingleTableDatabaseInitializer.java
/** * Sets the column names which will be used to create a DDL definition * of the columns for the table./*from w w w .ja va2 s . co m*/ */ public void setColumnNames(String[] names) { Assert.notEmpty(names, "columnNames cannot be empty"); StringBuilder columns = new StringBuilder(); for (String column : names) { if (columns.length() > 0) { columns.append(", "); } columns.append(column).append(" varchar(2000) "); } this.columns = columns.toString(); }
From source file:org.springframework.xd.module.core.ModuleFactory.java
/** * Create a composite module based on the provided {@link ModuleDescriptor}, * {@link org.springframework.xd.module.options.ModuleOptions}, and * {@link org.springframework.xd.module.ModuleDeploymentProperties}. * * @param compositeDescriptor descriptor for the composed module * @param options module options for the composed module * @param deploymentProperties deployment related properties for the composed module * @return new composed module instance/*w ww. j a va 2s. co m*/ * @see ModuleDescriptor#isComposed */ private Module createCompositeModule(ModuleDescriptor compositeDescriptor, ModuleOptions options, ModuleDeploymentProperties deploymentProperties) { List<ModuleDescriptor> children = compositeDescriptor.getChildren(); Assert.notEmpty(children, "child module list must not be empty"); if (log.isInfoEnabled()) { log.info("creating composite module " + compositeDescriptor); } List<Module> childrenModules = new ArrayList<Module>(children.size()); for (ModuleDescriptor moduleDescriptor : children) { ModuleOptions moduleOptions = new PrefixNarrowingModuleOptions(options, moduleDescriptor.getModuleName()); // due to parser results being reversed, we add each at index 0 // todo: is it right to pass the composite deploymentProperties here? childrenModules.add(0, createAndConfigureModuleInstance(moduleDescriptor, moduleOptions, deploymentProperties)); } return new CompositeModule(compositeDescriptor, deploymentProperties, childrenModules); }
From source file:org.springframework.xml.validation.XmlValidatorFactory.java
/** * Create a {@link XmlValidator} with the given schema resources and schema language type. The schema language must * be one of the <code>SCHEMA_XXX</code> constants. * * @param schemaResources an array of resource that locate the schemas to validate against * @param schemaLanguage the language of the schemas * @return a validator//from ww w . j a va 2s .c o m * @throws IOException if the schema resource cannot be read * @throws IllegalArgumentException if the schema language is not supported * @throws IllegalStateException if JAXP 1.0 cannot be located * @throws XmlValidationException if a <code>XmlValidator</code> cannot be created * @see #SCHEMA_RELAX_NG * @see #SCHEMA_W3C_XML */ public static XmlValidator createValidator(Resource[] schemaResources, String schemaLanguage) throws IOException { Assert.notEmpty(schemaResources, "No resources given"); Assert.hasLength(schemaLanguage, "No schema language provided"); Assert.isTrue(SCHEMA_W3C_XML.equals(schemaLanguage) || SCHEMA_RELAX_NG.equals(schemaLanguage), "Invalid schema language: " + schemaLanguage); for (Resource schemaResource : schemaResources) { Assert.isTrue(schemaResource.exists(), "schema [" + schemaResource + "] does not exist"); } if (JaxpVersion.getJaxpVersion() >= JaxpVersion.JAXP_13) { logger.trace("Creating JAXP 1.3 XmlValidator"); return Jaxp13ValidatorFactory.createValidator(schemaResources, schemaLanguage); } else { throw new IllegalStateException("Could not locate JAXP 1.3."); } }
From source file:org.springframework.xml.xsd.commons.CommonsXsdSchemaCollection.java
public void afterPropertiesSet() throws IOException { Assert.notEmpty(xsdResources, "'xsds' must not be empty"); schemaCollection.setSchemaResolver(uriResolver); Set<XmlSchema> processedIncludes = new HashSet<XmlSchema>(); Set<XmlSchema> processedImports = new HashSet<XmlSchema>(); for (Resource xsdResource : xsdResources) { Assert.isTrue(xsdResource.exists(), xsdResource + " does not exit"); try {/* www .j av a 2 s. co m*/ XmlSchema xmlSchema = schemaCollection.read(SaxUtils.createInputSource(xsdResource)); xmlSchemas.add(xmlSchema); if (inline) { inlineIncludes(xmlSchema, processedIncludes, processedImports); findImports(xmlSchema, processedImports, processedIncludes); } } catch (Exception ex) { throw new CommonsXsdSchemaException("Schema [" + xsdResource + "] could not be loaded", ex); } } if (logger.isInfoEnabled()) { logger.info("Loaded " + StringUtils.arrayToCommaDelimitedString(xsdResources)); } }
From source file:org.springmodules.workflow.osworkflow.configuration.ConfigurationBean.java
/** * Sets the arguments to be passed to the persistence object. *//*from w w w. j ava2 s. c om*/ public void setPersistenceArgs(Map persistenceArgs) { Assert.notEmpty(persistenceArgs, "persistenceArgs cannot be null or empty"); this.persistenceArgs = persistenceArgs; }