List of usage examples for org.springframework.util StringUtils hasLength
public static boolean hasLength(@Nullable String str)
From source file:com.qpark.eip.core.failure.FailureAssert.java
/** * Assert that the given text does not contain the given substring. * * <pre class="code">//from w w w.j a va 2 s.com * Assert.doesNotContain(name, "rod", "Name must not contain 'rod'"); * </pre> * * @param textToSearch * the text to search * @param substring * the substring to find within the text * @param errorCode * the error code to use if the assertion fails */ public static void doesNotContain(final String textToSearch, final String substring, final String errorCode) { if (StringUtils.hasLength(textToSearch) && StringUtils.hasLength(substring) && textToSearch.indexOf(substring) != -1) { BaseFailureHandler.throwFailureException(errorCode, textToSearch); } }
From source file:git.irbis.spring3.controllerusageexample.customers.web.ListCustomersCommandFactory.java
static ListCustomersCommandFactory parseFirstLastName(String firstName, String lastName) { return new ListCustomersCommandFactory(StringUtils.hasLength(firstName) ? firstName : null, StringUtils.hasLength(lastName) ? lastName : null); }
From source file:am.ik.support.morphia.ObjectIdEditor.java
@Override public void setAsText(String text) throws IllegalArgumentException { if (!StringUtils.hasLength(text) || "_empty".equals(text)) { setValue(null);/*w ww . java 2 s . c o m*/ } else { setValue(new ObjectId(text)); } }
From source file:org.hydroponics.web.validator.GrowValidator.java
public void validate(GrowEditBean book, Errors errors) { String name = book.getName(); if (!StringUtils.hasLength(name)) { errors.rejectValue("name", "required", "required"); }//from ww w. j a v a 2s . c o m }
From source file:com.rambird.miles.web.PetValidator.java
public void validate(Pet pet, Errors errors) { String name = pet.getName();// www . ja va 2 s .c o m 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:org.mum.samples.etrip.web.PetValidator.java
public void validate(Pet pet, Errors errors) { String name = pet.getName();// w ww .j a va 2s .com 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"); } else if (pet.isNew() && pet.getType() == null) { errors.rejectValue("type", "required", "required"); } }
From source file:com.jaxio.celerio.configuration.entity.CustomAnnotation.java
public boolean hasAnnotation() { return StringUtils.hasLength(annotation); }
From source file:com.branded.holdings.qpc.web.PetValidator.java
public void validate(Pet pet, Errors errors) { String name = pet.getName();/* w ww . ja v a 2 s . c om*/ // name validaation 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"); } // type valication if (pet.isNew() && pet.getType() == null) { errors.rejectValue("type", "required", "required"); } // type valication if (pet.getBirthDate() == null) { errors.rejectValue("birthDate", "required", "required"); } }
From source file:org.hsweb.web.core.datasource.DatabaseType.java
public static DatabaseType fromJdbcUrl(String url) { if (StringUtils.hasLength(url)) { Assert.isTrue(url.startsWith("jdbc"), "URL must start with 'jdbc'"); String urlWithoutPrefix = url.substring("jdbc".length()).toLowerCase(); for (DatabaseType driver : values()) { String prefix = ":" + driver.name().toLowerCase() + ":"; if (driver != unknown && urlWithoutPrefix.startsWith(prefix)) { return driver; }//from w w w . j a v a 2 s . c o m } } return unknown; }
From source file:com.example.securelogin.app.common.validation.UploadFileRequiredValidator.java
@Override public boolean isValid(MultipartFile multipartFile, ConstraintValidatorContext context) { return multipartFile != null && StringUtils.hasLength(multipartFile.getOriginalFilename()); }