de.smartics.util.lang
Class Arg

java.lang.Object
  extended by de.smartics.util.lang.Arg

public final class Arg
     
     
extends Object

Utility class to check an argument.


Method Summary
static
<T extends CharSequence>
T
checkNotBlank(String name, T value)
          Checks if value is blank.
static
<T extends CharSequence>
T
checkNotBlank(String name, T value, String message)
          Checks if value is blank providing an additional message.
static
<T extends CharSequence>
T
checkNotBlankExceptNull(String name, T value)
          Checks if value is blank except null.
static
<T extends CharSequence>
T
checkNotBlankExceptNull(String name, T value, String message)
          Checks if value is blank except null providing an additional message.
static
<T> T
checkNotNull(String name, T value)
          Checks if value is null.
static
<T> T
checkNotNull(String name, T value, String message)
          Checks if value is null providing an additional message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

checkNotNull

public static <T> T checkNotNull(String name,
                                 T value)
                      throws NullPointerException
Checks if value is null.

Type Parameters:
T - the type of the argument to check.
Parameters:
name - the name of the argument of error reporting. Not used if no exception is thrown. May be null, although not recommended.
value - the value of the argument to check to be not null.
Returns:
the passed in value.
Throws:
NullPointerException - if value is null.

checkNotNull

public static <T> T checkNotNull(String name,
                                 T value,
                                 String message)
                      throws NullPointerException
Checks if value is null providing an additional message.

Type Parameters:
T - the type of the argument to check.
Parameters:
name - the name of the argument of error reporting. Not used if no exception is thrown. May be null, although not recommended.
value - the value of the argument to check to be not null.
message - the message to pass to the exception as additional information to the standard message being generated.
Returns:
the passed in value.
Throws:
NullPointerException - if value is null.

checkNotBlank

public static <T extends CharSequence> T checkNotBlank(String name,
                                                       T value)
                                            throws NullArgumentException,
                                                   BlankArgumentException
Checks if value is blank.

Type Parameters:
T - a character sequence like a String.
Parameters:
name - the name of the argument of error reporting. Not used if no exception is thrown. May be null, although not recommended.
value - the value of the argument to check to be not blank.
Returns:
the passed in value.
Throws:
NullArgumentException - if value is null.
BlankArgumentException - if value is blank.

checkNotBlank

public static <T extends CharSequence> T checkNotBlank(String name,
                                                       T value,
                                                       String message)
                                            throws NullArgumentException,
                                                   BlankArgumentException
Checks if value is blank providing an additional message.

Type Parameters:
T - a character sequence like a String.
Parameters:
name - the name of the argument of error reporting. Not used if no exception is thrown. May be null, although not recommended.
value - the value of the argument to check to be not blank.
message - the message to pass to the exception as additional information to the standard message being generated.
Returns:
the passed in value.
Throws:
NullArgumentException - if value is null.
BlankArgumentException - if value is blank.

checkNotBlankExceptNull

public static <T extends CharSequence> T checkNotBlankExceptNull(String name,
                                                                 T value)
                                                      throws BlankExceptNullArgumentException
Checks if value is blank except null.

Type Parameters:
T - a character sequence like a String.
Parameters:
name - the name of the argument of error reporting. Not used if no exception is thrown. May be null, although not recommended.
value - the value of the argument to check to be not blank but may be null.
Returns:
the passed in value.
Throws:
BlankExceptNullArgumentException - if value is blank and not null.

checkNotBlankExceptNull

public static <T extends CharSequence> T checkNotBlankExceptNull(String name,
                                                                 T value,
                                                                 String message)
                                                      throws BlankExceptNullArgumentException
Checks if value is blank except null providing an additional message.

Type Parameters:
T - a character sequence like a String.
Parameters:
name - the name of the argument of error reporting. Not used if no exception is thrown. May be null, although not recommended.
value - the value of the argument to check to be not blank but may be null.
message - the message to pass to the exception as additional information to the standard message being generated.
Returns:
the passed in value.
Throws:
BlankExceptNullArgumentException - if value is blank and not null.


Copyright © 2011–2013 smartics. All rights reserved.