-->
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 validator on generic set ?
PostPosted: Tue Mar 23, 2010 7:27 am 
Newbie

Joined: Sun Apr 02, 2006 4:33 pm
Posts: 7
hi

I'm trying to create a validator for a Set<T>, like that :
Code:
SampleClass<T extends Foo> implements SampleInterface<T>{

@CustomValidOnGenericSet
private Set<T> foos = new HashSet<T>();

}


However, I don't manage to reflect this generic type in the validator.

The only working solution I found was to completely skip the generic part:
Code:
public class CustomValidOnGenericSetValidator implements ConstraintValidator<MyValidator, Set>


this looks pretty poor, is there a way I could do it cleanly ?

If not, does it mean that it I wanted to add a validator on some generic a field, then I would have to create a validator on top of Object ?
In code, this would mean :
Code:
SampleClass<T extends Foo> implements SampleInterface<T>{

@CustomValid
private T initialT;
}

class CustomValidator implements ConstraintValidator<MyValidator, Object>{
...
}


thanks in advance

best regards
zedros


Top
 Profile  
 
 Post subject: Re: Custom validator on generic set ?
PostPosted: Fri Aug 20, 2010 5:10 pm 
Newbie

Joined: Thu Jul 05, 2007 5:30 pm
Posts: 8
I am not sure if I got it right, but wouldn't ConstraintValidator<MyValidator, Set<?>> be what you are looking for as syntax?
However this will not make the big difference.

Regards
Jörg


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.