com.faunos.util
Class Validator<E extends RuntimeException>

java.lang.Object
  extended by com.faunos.util.Validator<E>

public class Validator<E extends RuntimeException>
extends Object

A validation and exception raising factory. This only works if the exception to be thrown is an unchecked exception. The idea is that the indirection provides a centralized place for code to reconfigure the type of exceptions thrown.


Field Summary
static Validator<IllegalArgumentException> ARG
           
static Validator<IllegalStateException> STATE
           
 
Constructor Summary
Validator(Class<E> exceptionClass)
           
 
Method Summary
protected  E createRuntimeException(String message)
           
static Validator<IllegalArgumentException> defaultInstance()
           
 void fail()
           
 void fail(String message)
           
 void fail(String message, Throwable cause)
           
 void fail(Throwable cause)
           
 void inRange(long minValue, long maxValue, long value)
           
 void inRange(long minValue, long maxValue, long value, String message)
           
 void isTrue(boolean truth)
           
 void isTrue(boolean truth, String message)
           
 void nonNegative(long value)
           
 void nonNegative(long value, String message)
           
 void notEmpty(CharSequence string)
           
 void notEmpty(CharSequence string, String message)
           
 void notEmpty(Collection<?> collection)
           
 void notEmpty(Collection<?> collection, String message)
           
 void notEmpty(Object[] array)
           
 void notEmpty(Object[] array, String message)
           
 void notNull(Object obj)
           
 void notNull(Object obj, String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ARG

public static final Validator<IllegalArgumentException> ARG

STATE

public static final Validator<IllegalStateException> STATE
Constructor Detail

Validator

public Validator(Class<E> exceptionClass)
Method Detail

defaultInstance

public static Validator<IllegalArgumentException> defaultInstance()

isTrue

public void isTrue(boolean truth)

isTrue

public void isTrue(boolean truth,
                   String message)

notNull

public void notNull(Object obj)

notNull

public void notNull(Object obj,
                    String message)

notEmpty

public void notEmpty(Collection<?> collection)

notEmpty

public void notEmpty(Collection<?> collection,
                     String message)

notEmpty

public void notEmpty(Object[] array)

notEmpty

public void notEmpty(Object[] array,
                     String message)

notEmpty

public void notEmpty(CharSequence string)

notEmpty

public void notEmpty(CharSequence string,
                     String message)

inRange

public void inRange(long minValue,
                    long maxValue,
                    long value,
                    String message)

inRange

public void inRange(long minValue,
                    long maxValue,
                    long value)

fail

public void fail()

fail

public void fail(String message)

fail

public void fail(Throwable cause)

fail

public void fail(String message,
                 Throwable cause)

createRuntimeException

protected E createRuntimeException(String message)

nonNegative

public void nonNegative(long value,
                        String message)

nonNegative

public void nonNegative(long value)


SourceForge.net Logo