It says that I can pass any object into it.for example ,conside I pass an object A,here want to constraint on the object A ,A should have a "int" parameter in it and its value should be greater than 10 otherwise ,the method won't accept the object.How It can be done ?.
set some precondition for the object pass into method
I like to do declarativelly rather than programmatically.How it can be dome?
Joined: May 11, 2005
As far as I know it cant be done declaratively. You could use an aspect to advise the entry to the method and inspect the object passed in the aspect instead of the actual method, but in either case you have to write some code to do it....as far as I know anyway.
Actually just off the top of my head (may be way off) but could write some form of custom annotation?
You definitely can't use any kind of compile-time construct to accept or reject argments based on member values, since members only exist and have values while a program is running, long after the compiler has done its job.
The only preconditions you can set are type restrictions like "List<T extends JComponent>", which accepts only JComponent or its subclasses.