Example usage for org.springframework.util Assert hasText

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

Introduction

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

Prototype

public static void hasText(@Nullable String text, Supplier<String> messageSupplier) 

Source Link

Document

Assert that the given String contains valid text content; that is, it must not be null and must contain at least one non-whitespace character.

Usage

From source file:com.github.totyumengr.minicubes.core.FactTable.java

private FactTable(String name) {
    // Internal/*w w  w .  j  a v a 2  s.co  m*/
    Meta meta = new Meta();
    meta.name = name;
    Assert.hasText(name, "Fact-table name can not empty.");

    this.meta = meta;
    this.records = new HashMap<Integer, FactTable.Record>(0);
    ;
}

From source file:grails.plugin.springsecurity.web.access.GrailsWebInvocationPrivilegeEvaluator.java

protected FilterInvocation createFilterInvocation(final String contextPath, final String uri,
        final String method) {
    Assert.hasText(uri, "URI required");
    return new FilterInvocation(DummyRequestCreator.createInstance(contextPath, method, contextPath + uri),
            DUMMY_RESPONSE, DUMMY_CHAIN);
}

From source file:lab.mage.spring.cassandra.connector.core.CassandraSessionProvider.java

@Nonnull
public Session getTenantSession(@Nonnull final String identifier) {
    Assert.notNull(identifier, "A tenant identifier must be given!");
    Assert.hasText(identifier, "A tenant identifier must be given!");

    final Mapper<TenantInfo> tenantInfoMapper = this.getAdminSessionMappingManager().mapper(TenantInfo.class);
    tenantInfoMapper.setDefaultDeleteOptions(OptionProvider.deleteConsistencyLevel(this.env));
    tenantInfoMapper.setDefaultGetOptions(OptionProvider.readConsistencyLevel(this.env));
    tenantInfoMapper.setDefaultSaveOptions(OptionProvider.writeConsistencyLevel(this.env));
    final TenantInfo tenantInfo = tenantInfoMapper.get(identifier);
    Assert.notNull(tenantInfo, "Tenant [" + identifier + "] unknown!");
    return this.getSession(tenantInfo.getClusterName(), tenantInfo.getContactPoints(),
            tenantInfo.getKeyspace());//from w  w w. ja v a2s.c om
}

From source file:com.autentia.wuija.reports.JasperReportsService.java

/**
 * generate the report//from w  w w  . j  av a  2s.c o  m
 * 
 * @param outputName name of the report generated, can be null
 * @param report the report
 * @param format format for report
 * @param args arguments of the report
 * @param con database connection
 * @return File the report generated
 * @throws JRException
 */
public File generateReport(String reportName, String outputName, Format format, Map<String, Object> params) {
    Assert.hasText(reportName, "reportName must not be empty");
    if (log.isDebugEnabled()) {
        log.debug("reportName='" + reportName + "'");
        log.debug("format='" + format + "'");
    }

    final JasperReport report = compileReportAndSubreports(reportName);

    final ByteArrayOutputStream output = exportReportToOutputStream(report, format, params);

    final String fileName = StringUtils.isBlank(outputName) ? report.getName() : outputName;
    final File file = JasperReportsHelper.writeExportedReportToFile(fileName, format, output);

    if (log.isTraceEnabled()) {
        log.trace("file='" + file.getPath() + "' generated.");
    }
    return file;
}

From source file:org.red5.server.script.groovy.GroovyScriptFactory.java

@SuppressWarnings({ "rawtypes" })
public GroovyScriptFactory(String scriptSourceLocator, Class[] scriptInterfaces) {
    Assert.hasText(scriptSourceLocator, "'scriptSourceLocator' must not be empty");
    this.scriptSourceLocator = scriptSourceLocator;
    this.groovyObjectCustomizer = null;
    //      this(scriptSourceLocator, null);
    if (null == scriptInterfaces || scriptInterfaces.length < 1) {
        this.scriptInterfaces = new Class[] {};
    } else {/*from w ww. j a  v  a2  s.  c  om*/
        this.scriptInterfaces = scriptInterfaces;
    }
}

From source file:nl.surfnet.coin.ldap.LdapClientImpl.java

private Filter getFilter(String... identifiers) {
    OrFilter orFilter = new OrFilter();
    for (String identifier : identifiers) {
        Assert.hasText(identifier, "Identifier may not be null or empty when searching for a Person");
        String searchAttribute = "collabpersonid";
        if (!identifier.startsWith(URN_IDENTIFIER)) {
            searchAttribute = "collabpersonuuid";
            identifier = engineBlock.getUserUUID(identifier);
        }/*from  w  w  w .  ja v a 2s.co m*/
        orFilter.or(new EqualsFilter(searchAttribute, identifier));
    }
    return orFilter;
}

From source file:org.mybatis.spring.ext.core.annotation.AnnotationAttributes.java

@SuppressWarnings("unchecked")
private <T> T doGet(String attributeName, Class<T> expectedType) {
    Assert.hasText(attributeName, "attributeName must not be null or empty");
    Object value = this.get(attributeName);
    Assert.notNull(value, format("Attribute '%s' not found", attributeName));
    Assert.isAssignable(expectedType, value.getClass(),
            format("Attribute '%s' is of type [%s], but [%s] was expected. Cause: ", attributeName,
                    value.getClass().getSimpleName(), expectedType.getSimpleName()));
    return (T) value;
}

From source file:at.pagu.soldockr.core.query.Criteria.java

/**
 * Creates a new Criteria for the given field
 * //www .  ja  va  2 s .c  o  m
 * @param field
 */
public Criteria(Field field) {
    Assert.notNull(field, "Field for criteria must not be null");
    Assert.hasText(field.getName(), "Field.name for criteria must not be null/empty");

    this.criteriaChain.add(this);
    this.field = field;
}

From source file:spring.osgi.utils.OsgiBundleUtils.java

/**
 * Finds an install bundle based by its symbolic name.
 *
 * @param bundleContext OSGi bundle context
 * @param symbolicName  bundle symbolic name
 * @return bundle matching the symbolic name (<code>null</code> if none
 * is found)// www  .ja  va  2  s  .  c om
 */
public static Bundle findBundleBySymbolicName(BundleContext bundleContext, String symbolicName) {
    Assert.notNull(bundleContext, "bundleContext is required");
    Assert.hasText(symbolicName, "a not-null/not-empty symbolicName isrequired");

    Bundle[] bundles = bundleContext.getBundles();
    for (Bundle bundle : bundles) {
        if (symbolicName.equals(bundle.getSymbolicName())) {
            return bundle;
        }
    }
    return null;
}