title: design pattern to validate the requests?
body: <p>I have below the interface. I am using Java 7 and Spring 3.0</p>
  
  <pre><code>public interface Maintain{
  
   void save(Request request);
   Request getRequest(String id);
   void delete(Request request);
   void update(Request request);
  
  }
  
  public class MaintainImpl implements Maintain{
  
  
   public void save(Request request){
  
    //Need to validate the request before saving.
    //Need to throw run time exception if validation fails
  
   }
  
   public void getRequest(String id){
  
    //Need to validate the id before getting the results.
    //Need to throw run time exception if validation fails
  
   }
  
    //Similarly i  need to implement other 2 methods
  
  
  }
  </code></pre>
  
  <p>To validate the requests:
  I am planning to write one Interface and 4 impl classes which will have validation logic.</p>
  
  <pre><code>public interface validate{
  
   boolan validate();
  }
  
  
  
  public class SaveRequestValidator implements validate{
  
       public boolean validate(){
       //validation logic
      }
  
     }
  
  
  
  
  
   public class GetRequestValidator implements validate{
  
       public boolean validate(){
       //validation logic
      }
  
     }
  
  
  
  
  public class DeleteRequestValidator implements validate{
  
       public boolean validate(){
       //validation logic
      }
  
     }
  
  
  
  public class UpdateRequestValidator implements validate{
  
       public boolean validate(){
       //validation logic
      }
  
     }
  </code></pre>
  
  <p>Now can i perform validations by injecting all these four validators into <strong>MaintainImpl.java</strong> ?</p>
  
  <p>Is it good practice? Is there any better design? OR can i keep all validations in one class and provide static methods?</p>
  
  <p>Thanks!</p>