KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > hibernate > validator > NotNullValidator


1 //$Id: NotNullValidator.java,v 1.1 2005/05/27 08:58:54 epbernard Exp $
2
package org.hibernate.validator;
3
4 import java.util.Iterator JavaDoc;
5
6 import org.hibernate.mapping.Column;
7 import org.hibernate.mapping.Property;
8
9 /**
10  * Check a not null restriction on an object
11  * and apply the equivalent constraint on hibernate metadata.
12  *
13  * @author Gavin King
14  */

15 public class NotNullValidator implements Validator<NotNull>, PropertyConstraint {
16
17     public boolean isValid(Object JavaDoc value) {
18         return value!=null;
19     }
20
21     public void initialize(NotNull parameters) {}
22
23     public void apply(Property property) {
24         Iterator JavaDoc<Column> iter = (Iterator JavaDoc<Column>) property.getColumnIterator();
25         while ( iter.hasNext() ) {
26             iter.next().setNullable(false);
27         }
28     }
29 }
30
Popular Tags