Example usage for org.springframework.util StringUtils hasLength

List of usage examples for org.springframework.util StringUtils hasLength

Introduction

In this page you can find the example usage for org.springframework.util StringUtils hasLength.

Prototype

public static boolean hasLength(@Nullable String str) 

Source Link

Document

Check that the given String is neither null nor of length 0.

Usage

From source file:com.example.securelogin.app.common.validation.UploadFileNotEmptyValidator.java

@Override
public boolean isValid(MultipartFile multipartFile, ConstraintValidatorContext context) {
    if (multipartFile == null || !StringUtils.hasLength(multipartFile.getOriginalFilename())) {
        return true;
    }//from w  w w.  j  av a2 s  .co  m
    return !multipartFile.isEmpty();
}

From source file:com.jklas.sample.petclinic.validation.PetValidator.java

public void validate(Object obj, Errors errors) {
    Pet pet = (Pet) obj;//  w w  w .j a  v a2s  .c  o  m
    String name = pet.getName();
    if (!StringUtils.hasLength(name)) {
        errors.rejectValue("name", "required", "required");
    } else if (pet.isNew() && pet.getOwner().getPet(name, true) != null) {
        errors.rejectValue("name", "duplicate", "already exists");
    }
}

From source file:com.jaxio.celerio.configuration.entity.Inheritance.java

public boolean hasParentEntityName() {
    return StringUtils.hasLength(parentEntityName);
}

From source file:io.pivotal.util.MarkdownEngine.java

@Override
public String convert(String text) {
    if (!StringUtils.hasLength(text)) {
        return "";
    }/*from w  w  w. j ava2  s. c o  m*/
    text = header(text);
    text = text.replaceAll("\\{(code|noformat)(:(\\w+))?(?:(:|\\|)\\w+=.+?)*\\}", "```$3 ");
    text = text.replaceAll("(```\\w*) (.+)", "$1\n$2");
    text = text.replaceAll("(.)(```) ", "$1\n$2");
    text = text.replaceAll("\\[(.+?)\\|(http.*?)\\]", "[$1]($2)");
    text = text.replaceAll("\\{\\{(.+?)\\}\\}", "`$1`");
    text = quote(text);
    return text.replaceAll("\\[~([\\w]+)\\]", "[$1](" + jiraBaseUrl + "/secure/ViewProfile.jspa?name=$1)");
}

From source file:org.springmodules.validation.bean.conf.loader.annotation.handler.ValidationMethodAnnotationHandler.java

protected String extractErrorCode(Annotation annotation) {
    String errorCode = super.extractErrorCode(annotation);
    return (StringUtils.hasLength(errorCode)) ? errorCode : null;
}

From source file:grails.plugin.cache.web.filter.DefaultWebKeyGenerator.java

public String generate(HttpServletRequest request) {

    String uri = WebUtils.getForwardURI(request);

    StringBuilder key = new StringBuilder();
    key.append(request.getMethod().toUpperCase());

    String format = WebUtils.getFormatFromURI(uri);
    if (StringUtils.hasLength(format) && !"all".equals(format)) {
        key.append(":format:").append(format);
    }//from w  w w. ja va 2s. c  o  m

    if (supportAjax) {
        String requestedWith = request.getHeader(X_REQUESTED_WITH);
        if (StringUtils.hasLength(requestedWith)) {
            key.append(':').append(X_REQUESTED_WITH).append(':').append(requestedWith);
        }
    }

    key.append(':').append(uri);
    if (StringUtils.hasLength(request.getQueryString())) {
        key.append('?').append(request.getQueryString());
    }

    return key.toString();
}

From source file:org.cruxframework.mediamanager.model.spring.filter.CustomOpenEntityManagerInViewFilter.java

/**
 * {@inheritDoc}//from  w  w w.  j  ava2  s  .  c  om
 */
@Override
protected EntityManagerFactory lookupEntityManagerFactory() {
    String emfBeanName = getEntityManagerFactoryBeanName();
    String puName = getPersistenceUnitName();
    if (StringUtils.hasLength(emfBeanName)) {
        return SpringUtils.get().getBean(emfBeanName, EntityManagerFactory.class);
    } else if (!StringUtils.hasLength(puName)
            && SpringUtils.get().containsBean(DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME)) {
        return SpringUtils.get().getBean(DEFAULT_ENTITY_MANAGER_FACTORY_BEAN_NAME, EntityManagerFactory.class);
    } else {
        // Includes fallback search for single EntityManagerFactory bean by type.
        return EntityManagerFactoryUtils.findEntityManagerFactory(SpringUtils.get().getContext(), puName);
    }
}

From source file:io.pivotal.util.TextileEngine.java

@Override
public String convert(String text) {
    if (!StringUtils.hasLength(text)) {
        return "";
    }/*from w  ww  . ja  va  2  s  .c o m*/
    text = blockCode(text);
    text = text.replaceAll("\\[(.+?)\\|(http.*?)\\]", "[\"$1\":$2]");
    text = text.replaceAll("\\{\\{(.+?)\\}\\}", "@$1@");
    return text.replaceAll("\\[~([\\w]+)\\]", "[\"$1\":" + jiraBaseUrl + "/secure/ViewProfile.jspa?name=$1]");
}

From source file:com.gigaspaces.persistency.MongoClientConnectorConfigurer.java

public MongoClientConnector create() {

    if (!StringUtils.hasLength(db))
        throw new IllegalArgumentException("Argument cannot be null or empty: db");

    if (client == null)
        throw new IllegalArgumentException("Argument cannot be null or empty: config");

    return new MongoClientConnector(client, db);
}

From source file:com.excilys.ebi.spring.dbunit.utils.DbUnitUtils.java

public static DatabaseConnection getDatabaseConnection(Connection connection, String schema,
        DatabaseConnectionConfigurer databaseConnectionConfigurer) throws DatabaseUnitException {

    DatabaseConnection databaseConnection = StringUtils.hasLength(schema)
            ? new DatabaseConnection(connection, schema)
            : new DatabaseConnection(connection);
    DatabaseConfig databaseConfig = databaseConnection.getConfig();
    databaseConnectionConfigurer.configure(databaseConfig);

    return databaseConnection;
}