Example usage for org.apache.commons.validator.routines EmailValidator getClass

List of usage examples for org.apache.commons.validator.routines EmailValidator getClass

Introduction

In this page you can find the example usage for org.apache.commons.validator.routines EmailValidator getClass.

Prototype

@HotSpotIntrinsicCandidate
public final native Class<?> getClass();

Source Link

Document

Returns the runtime class of this Object .

Usage

From source file:org.bml.util.args.ArgumentUtils.java

/**
 * <p>/*from  w w w  . j  a v a 2  s .  com*/
 * Validation method for email addresses both local and network.
 * </p>
 *
 * @param email The potential email address to be validated.
 * @param allowLocal True if the email address can be a local address, false otherwise
 * @throws IllegalArgumentException if any pre-conditions are not met or if the passed email does not validate as an email address.
 * @pre email != null
 * @pre !email.isEmpty()
*@deprecated This class and method has been depreciated in favor of a combination of {@link org.apache.commons.validator.Validator} and {@link com.google.common.base.Preconditions} framework which provides the same and broader functionality with greater flexibility.
 */
public static void checkEmail(final String email, final boolean allowLocal) throws IllegalArgumentException {
    ArgumentUtils.checkStringArg(email, "email address", false, false);
    //This may be able to be cached. There are stil some reported thread saftey issues with commons validator
    EmailValidator validator = EmailValidator.getInstance(allowLocal);
    if (!validator.isValid(email)) {
        throw new IllegalArgumentException("String passed does not pass vaidation by "
                + validator.getClass().getName() + " implementation. Not a vaild email address.");
    }
}