Let say I want to check condition[let say boundary values] on some of the method arguments.Instead of writing "if" condition to check [boundary condition] on every method, I want to annotate argument only. Let me know the Steps to understand it. Working code will be awesome.
            Asked
            
        
        
            Active
            
        
            Viewed 169 times
        
    0
            
            
        - 
                    2http://docs.oracle.com/javase/tutorial/java/annotations/. Annotations don't do anything. They just add metadata to the code. You would need a tool, at runtime, to read those annotations and do something with them. – JB Nizet Mar 14 '15 at 14:58
 - 
                    Might help you http://stackoverflow.com/a/27781761/1697099 and http://stackoverflow.com/a/5686231/1697099 – Premraj Jul 02 '15 at 13:32
 
1 Answers
1
            You need to look into method interception. What you are wanting is an interceptor that can validate method arguments on invocation. I like the AOP Alliance interfaces for this, they work pretty well. It also integrates with Guice natively and I think Spring has support for it as well.
Steps:
- Define an annotation
 - Create an interceptor to process the annotation
 - Bind the interceptor (manually or using some framework)
 
        toadzky
        
- 3,806
 - 1
 - 15
 - 26