Example usage for org.apache.commons.lang3 Validate notBlank

List of usage examples for org.apache.commons.lang3 Validate notBlank

Introduction

In this page you can find the example usage for org.apache.commons.lang3 Validate notBlank.

Prototype

public static <T extends CharSequence> T notBlank(final T chars, final String message, final Object... values) 

Source Link

Document

Validate that the specified argument character sequence is neither null , a length of zero (no characters), empty nor whitespace; otherwise throwing an exception with the specified message.

Usage

From source file:co.runrightfast.commons.utils.ValidationUtils.java

static void notBlank(final String val, @NonNull final String argName) {
    Validate.notBlank(val, "%s cannot be blank", argName);
}

From source file:io.github.swagger2markup.internal.type.BasicType.java

public BasicType(String type, String name, String format) {
    super(name);/*from w ww .  ja v a 2  s  . co m*/
    Validate.notBlank(type, "Type of parameter '%s' must not be blank", name);
    this.type = type;
    this.format = format;
}

From source file:com.mgmtp.jfunk.web.RemoteWebDriverProvider.java

@Override
protected WebDriver createWebDriver(final DesiredCapabilities capabilities) {
    String remoteWebDriverUrl = config.get(WebConstants.REMOTE_WEBDRIVER_URL, "");
    Validate.notBlank(remoteWebDriverUrl, "Property '%s' must be set in configuration",
            WebConstants.REMOTE_WEBDRIVER_URL);

    URL url;/*from w  w  w .  j  a v a 2 s  .com*/
    try {
        url = new URL(remoteWebDriverUrl);
    } catch (MalformedURLException e) {
        throw new IllegalArgumentException("Illegal remote web driver hub url: " + remoteWebDriverUrl);
    }

    log.info("Starting remote web driver with capabilitiesMap: {}", capabilitiesMap);
    return new Augmenter().augment(new RemoteWebDriver(url, capabilities));
}

From source file:com.premiumminds.billy.core.util.BillyValidator.java

public static <T extends CharSequence> T mandatory(T o, String fieldName) {
    Validate.notNull(o, BillyValidator.instance.localizer.getString("invalid.mandatory", fieldName), o);
    Validate.notBlank(o, BillyValidator.instance.localizer.getString("invalid.mandatory", fieldName), o);
    return o;//from w  w w.ja  va 2 s. c  om
}

From source file:com.premiumminds.billy.core.util.BillyValidator.java

public static <T extends CharSequence> T notBlank(T object, String fieldName) {
    Validate.notBlank(object, BillyValidator.instance.localizer.getString("invalid.blank", fieldName),
            fieldName);// ww w. j a  va2 s . c  o m
    return object;
}

From source file:com.premiumminds.billy.core.util.BillyValidator.java

public static <T extends CharSequence> T notBlankButNull(T object, String fieldName) {
    if (null != object) {
        Validate.notBlank(object, BillyValidator.instance.localizer.getString("invalid.blank", fieldName),
                fieldName);//w w w.java  2s  .com
    }
    return object;
}

From source file:com.feedzai.fos.common.validation.ValidationUtils.java

/**
 * Gets a <code>String</code> from the given configuration.
 *
 * @param configuration the configuration where the parameter lies
 * @param parameterName the name of the parameter
 * @return the <code>String</code>
 * @throws IllegalArgumentException if the parameter is null or blank
 *///from w  w w .j a  v a 2 s  .  c o  m
@NotBlank
public static String getStringNotBlank(Configuration configuration, @NotBlank String parameterName) {
    return Validate.notBlank(configuration.getString(parameterName), NOT_BLANK, parameterName);
}

From source file:uk.ac.cam.cl.dtg.segue.auth.GoogleAuthenticator.java

/**
 * Construct a google authenticator./* w w w.j a va2s.  co  m*/
 * 
 * @param clientSecretLocation
 *            - external file containing the secret provided by the google service.
 * @param callbackUri
 *            - The allowed URI for callbacks as registered with google.
 * @param requestedScopes
 *            - The scopes that will be granted to Segue.
 * @throws IOException
 *             - if we cannot load the secret file.
 */
@Inject
public GoogleAuthenticator(@Named(Constants.GOOGLE_CLIENT_SECRET_LOCATION) final String clientSecretLocation,
        @Named(Constants.GOOGLE_CALLBACK_URI) final String callbackUri,
        @Named(Constants.GOOGLE_OAUTH_SCOPES) final String requestedScopes) throws IOException {
    this.jsonFactory = new JacksonFactory();
    this.httpTransport = new NetHttpTransport();

    Validate.notBlank(clientSecretLocation, "Missing resource %s", clientSecretLocation);

    // load up the client secrets from the file system.
    InputStream inputStream = new FileInputStream(clientSecretLocation);
    InputStreamReader isr = new InputStreamReader(inputStream);

    clientSecrets = GoogleClientSecrets.load(new JacksonFactory(), isr);

    this.requestedScopes = Arrays.asList(requestedScopes.split(";"));
    this.callbackUri = callbackUri;

    if (null == credentialStore) {
        credentialStore = CacheBuilder.newBuilder()
                .expireAfterAccess(CREDENTIAL_CACHE_TTL_MINUTES, TimeUnit.MINUTES).<String, Credential>build();
    }

    if (null == tokenVerifier) {
        tokenVerifier = new GoogleIdTokenVerifier(httpTransport, jsonFactory);
    }
}