-->
These old forums are deprecated now and set to read-only. We are waiting for you on our new forums!
More modern, Discourse-based and with GitHub/Google/Twitter authentication built-in.

All times are UTC - 5 hours [ DST ]



Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 
Author Message
 Post subject: Custom constraints and class level constraints explained
PostPosted: Tue Apr 01, 2008 10:59 am 
Hibernate Team
Hibernate Team

Joined: Sun Sep 14, 2003 3:54 am
Posts: 7256
Location: Paris, France
Check this blog entry

_________________
Emmanuel


Top
 Profile  
 
 Post subject:
PostPosted: Sun Aug 31, 2008 12:22 pm 
Newbie

Joined: Sun Aug 31, 2008 9:05 am
Posts: 4
It's really promising the direction of JSR-303, so i'm hard to find some implementation that the people can play, so i see for now a user posted:
http://code.google.com/p/agimatec-validation/
that have a preliminary implementation, so will be great that a public read only repository will be available to people testing and discussing the JSR proposal.

I point here so i think its a better place a API change to better interoperability of implementation, discussed deeper in http://forum.hibernate.org/viewtopic.php?t=985983:

Split the Constraint interface into:

Code:
public interface Constraint {
   /**
   * does the object/element pass the constraints
   */
   public boolean isValid(Object value);
}


Code:
public interface InitializedConstraint<A extends Annotation> {
   /**
   * Take the annotations values
   *
   * @param parameters
   */
   public void initialize(A parameters);
}


This will make more simple Constraints implementations, constraints with initialization also implements InitializedConstraint so it can be initializad in a per instance basis.

NOTE: Could be great if a standard codding guide for constraints exists, include that constraints that implements InitializedConstraint implement setter/getter for parameters (Not needed in bean annotated but improve interoperability to use the constraint stand-alone).
With this considerations the use of the Constraints implementations in scenarios that not annotated bean exists at all, can be straightforward, so all constraints are treated as same: isValid(Object value), and some settter/getter if any to set parameters of the Constraint instance.

Really good work on this JSR :)

Regards.

_________________
Marcos Lois Bermúdez


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 2 posts ] 

All times are UTC - 5 hours [ DST ]


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
© Copyright 2014, Red Hat Inc. All rights reserved. JBoss and Hibernate are registered trademarks and servicemarks of Red Hat, Inc.