de.smartics.util.lang
Class ArgumentChecker

java.lang.Object
  extended by de.smartics.util.lang.ArgumentChecker
All Implemented Interfaces:
Serializable

@NotThreadSafe
public final class ArgumentChecker
     
     
extends Object
implements Serializable

Collects exceptions. Especially useful for builders.

See Also:
Serialized Form

Constructor Summary
ArgumentChecker(String message)
          Default constructor.
 
Method Summary
 void add(Throwable t)
          Adds a throwable.
 void check()
          Checks if an exception has been encountered.
 void notBlank(String name, String value)
          Checks if value is blank.
 void notBlankExceptNull(String name, String value)
          Checks if value is blank except null.
 void notNull(String name, Object value)
          Checks if value is null.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ArgumentChecker

public ArgumentChecker(String message)
                throws IllegalArgumentException
Default constructor.

Parameters:
message - the message to prepend to the message if throwables have been collected.
Throws:
IllegalArgumentException - if message is blank.
Method Detail

notNull

public void notNull(String name,
                    Object value)
Checks if value is null.

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.

notBlank

public void notBlank(String name,
                     String value)
Checks if value is blank.

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.

notBlankExceptNull

public void notBlankExceptNull(String name,
                               String value)
Checks if value is blank except null.

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.

add

public void add(Throwable t)
Adds a throwable.

Parameters:
t - the throwable to add.

check

public void check()
           throws IllegalArgumentException
Checks if an exception has been encountered.

Throws:
IllegalArgumentException - if at least on exception has been encountered.


Copyright © 2011–2013 smartics. All rights reserved.