001 package com.sptci.prevayler;
002
003 /**
004 * A custom exception used to indicate that a field marked as {@link
005 * com.sptci.prevayler.annotations.NotNull} is <code>null</code>.
006 *
007 * <p>© Copyright 2008 <a href='http://sptci.com/' target='_top'>Sans Pareil Technologies, Inc.</a></p>
008 * @author Rakesh 2008-05-23
009 * @version $Id: NullException.java 4345 2008-06-30 21:22:03Z rakesh $
010 */
011 public class NullException extends ConstraintException
012 {
013 private static final long serialVersionUID = 1L;
014
015 /** The pattern for displaying constraint violation. */
016 private static final String FIELD_PATTERN =
017 "NULL value on field: $FIELD$ in class: $CLASS$ prohibited!";
018
019 /**
020 * Create a new instance of the exception with the specified message.
021 *
022 * @param message The message to associate with the exception.
023 */
024 public NullException( final String message )
025 {
026 super( message );
027 }
028
029 /**
030 * Create a new instance of the exception using {@link #FIELD_PATTERN} to
031 * display the message for unique constraint on specified fields being
032 * violated.
033 *
034 * @param object The prevalent object for which the violation was raised.
035 * @param field The name of the field whose not-null constraint was
036 * violated.
037 */
038 public NullException( final PrevalentObject object, final String field )
039 {
040 super( FIELD_PATTERN.replace( "$CLASS$", object.getClass().getName() ).
041 replace( "$FIELD$", field ) );
042 }
043 }