Example usage for org.springframework.util Assert notEmpty

List of usage examples for org.springframework.util Assert notEmpty

Introduction

In this page you can find the example usage for org.springframework.util Assert notEmpty.

Prototype

public static void notEmpty(@Nullable Map<?, ?> map, Supplier<String> messageSupplier) 

Source Link

Document

Assert that a Map contains entries; that is, it must not be null and must contain at least one entry.

Usage

From source file:org.openflamingo.fs.s3.S3ObjectProvider.java

@Override
public List<String> delete(List<String> paths) {
    //        Assert.notEmpty(paths, "  ? ? ? 'files'?  .");
    Assert.notEmpty(paths, "Please enter the file path");

    List<String> notDeleted = new ArrayList<String>();

    for (String path : paths) {
        try {// w  w w  .j a  v  a 2 s.co m
            boolean result = !this.delete(path);
            /*
                            if (result && auditService != null)
            auditService.delete(FileSystemType.S3, username, path);
            */
            if (result) {
                notDeleted.add(path);
            }
        } catch (Exception ex) {
            //  ?  ? ?       ? ?  ?? .
            notDeleted.add(path);
        }
    }
    return null;
}

From source file:org.openflamingo.fs.s3.S3ObjectProvider.java

@Override
public List<String> move(List<String> filesPath, String to) {
    Assert.notEmpty(filesPath, "Please enter the source path.");
    Assert.hasLength(to, "Please enter the destination path.");

    List<String> notMoved = new ArrayList<String>();
    for (String file : filesPath) {
        boolean result = move(file, to);
        if (!result) {
            notMoved.add(file);//ww w  . j  a v  a  2  s  .c  o  m
        }
        if (result && auditService != null)
            ;
        // auditService.move(FileSystemType.S3, username, file, to);
    }
    return null;
}

From source file:org.openflamingo.fs.s3.S3ObjectProvider.java

@Override
public List<String> copy(List<String> files, String to) {
    //        Assert.notEmpty(files, " ? ? 'files'?  .");
    Assert.notEmpty(files, "Please enter the list of files.");
    //        Assert.hasLength(to, "??  ?  'to'?  .");
    Assert.hasLength(to, "Please enter the destination path.");

    List<String> notCopied = new ArrayList<String>();
    for (String file : files) {
        try {/*from   ww w. ja v  a  2s.c om*/
            boolean result = copy(file, to);
            if (!result) {
                notCopied.add(file);
            }
            /*
                            if (result && auditService != null)
            auditService.copy(FileSystemType.S3, username, file, to);
            */
        } catch (Exception ex) {
            //  ?  ? ?       ? ?  ?? .
            notCopied.add(file);
        }
    }
    return notCopied;
}

From source file:org.shept.org.springframework.web.servlet.mvc.support.ConfigurableLocaleDependentFormatResolver.java

public void afterPropertiesSet() throws Exception {
    Assert.notEmpty(this.dateTimeLocales, "The dateTimeLocales definitions have not yet been initialized");
    Assert.state(this.dateTimeLocales.containsKey(this.defaultLocale),
            "The default locale '" + this.defaultLocale + "' is not properly configured");
}

From source file:org.springframework.batch.item.xml.StaxEventItemReader.java

/**
 * Ensure that all required dependencies for the ItemReader to run are provided after all properties have been set.
 * //from www . j a  v  a 2  s.  co m
 * @see org.springframework.beans.factory.InitializingBean#afterPropertiesSet()
 * @throws IllegalArgumentException if the Resource, FragmentDeserializer or FragmentRootElementName is null, or if
 * the root element is empty.
 * @throws IllegalStateException if the Resource does not exist.
 */
@Override
public void afterPropertiesSet() throws Exception {
    Assert.notNull(unmarshaller, "The Unmarshaller must not be null.");
    Assert.notEmpty(fragmentRootElementNames, "The FragmentRootElementNames must not be empty");
    for (QName fragmentRootElementName : fragmentRootElementNames) {
        Assert.hasText(fragmentRootElementName.getLocalPart(),
                "The FragmentRootElementNames must not contain empty elements");
    }
}

From source file:org.springframework.boot.actuate.autoconfigure.ShellProperties.java

public void setCommandPathPatterns(String[] commandPathPatterns) {
    Assert.notEmpty(commandPathPatterns, "CommandPathPatterns must not be empty");
    this.commandPathPatterns = commandPathPatterns;
}

From source file:org.springframework.boot.actuate.autoconfigure.ShellProperties.java

public void setConfigPathPatterns(String[] configPathPatterns) {
    Assert.notEmpty(configPathPatterns, "ConfigPathPatterns must not be empty");
    this.configPathPatterns = configPathPatterns;
}

From source file:org.springframework.boot.autoconfigure.AutoConfigurationImportSelector.java

/**
 * Return the auto-configuration class names that should be considered. By default
 * this method will load candidates using {@link SpringFactoriesLoader} with
 * {@link #getSpringFactoriesLoaderFactoryClass()}.
 * @param metadata the source metadata//w ww.j  a v a2  s. c  o m
 * @param attributes the {@link #getAttributes(AnnotationMetadata) annotation
 * attributes}
 * @return a list of candidate configurations
 */
protected List<String> getCandidateConfigurations(AnnotationMetadata metadata,
        AnnotationAttributes attributes) {
    List<String> configurations = SpringFactoriesLoader.loadFactoryNames(getSpringFactoriesLoaderFactoryClass(),
            getBeanClassLoader());
    Assert.notEmpty(configurations, "No auto configuration classes found in META-INF/spring.factories. If you "
            + "are using a custom packaging, make sure that file is correct.");
    return configurations;
}

From source file:org.springframework.boot.SpringApplication.java

private ConfigurableApplicationContext doRun(SpringApplicationRunListeners listeners, String... args) {
    ConfigurableApplicationContext context;
    // Create and configure the environment
    ConfigurableEnvironment environment = getOrCreateEnvironment();
    configureEnvironment(environment, args);
    listeners.environmentPrepared(environment);
    if (isWebEnvironment(environment) && !this.webEnvironment) {
        environment = convertToStandardEnvironment(environment);
    }//w  w  w . j  av  a2  s  . c  o  m

    if (this.bannerMode != Banner.Mode.OFF) {
        printBanner(environment);
    }

    // Create, load, refresh and run the ApplicationContext
    context = createApplicationContext();
    context.setEnvironment(environment);
    postProcessApplicationContext(context);
    applyInitializers(context);
    listeners.contextPrepared(context);
    if (this.logStartupInfo) {
        logStartupInfo(context.getParent() == null);
        logStartupProfileInfo(context);
    }

    // Add boot specific singleton beans
    ApplicationArguments applicationArguments = new DefaultApplicationArguments(args);
    context.getBeanFactory().registerSingleton("springApplicationArguments", applicationArguments);

    // Load the sources
    Set<Object> sources = getSources();
    Assert.notEmpty(sources, "Sources must not be empty");
    load(context, sources.toArray(new Object[sources.size()]));
    listeners.contextLoaded(context);

    // Refresh the context
    refresh(context);
    if (this.registerShutdownHook) {
        try {
            context.registerShutdownHook();
        } catch (AccessControlException ex) {
            // Not allowed in some environments.
        }
    }
    afterRefresh(context, applicationArguments);
    listeners.finished(context, null);
    return context;
}

From source file:org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext.java

/**
 * Register one or more annotated classes to be processed. Note that
 * {@link #refresh()} must be called in order for the context to fully process the new
 * class.//from   ww  w  .j a v  a2s  .  c  om
 * <p>
 * Calls to {@code #register} are idempotent; adding the same annotated class more
 * than once has no additional effect.
 * @param annotatedClasses one or more annotated classes, e.g. {@code @Configuration}
 * classes
 * @see #scan(String...)
 * @see #refresh()
 */
@Override
public final void register(Class<?>... annotatedClasses) {
    Assert.notEmpty(annotatedClasses, "At least one annotated class must be specified");
    this.annotatedClasses.addAll(Arrays.asList(annotatedClasses));
}