title: How to dynamically define the Class that can be used as a parameter in a method?
body: <p>I have a method that I use to validate a POJO in Spring MVC (this allows me to rely on the <code>@Annotation</code> in the POJO and at the same time validate the POJO programmatically whenever and wherever I want without using the annotation <code>@Valid</code>).</p>
  
  <p>In need to pass the Class of the object to the method in order to validate: </p>
  
  <pre><code>public void validate(Class clazz, Object model, BindingResult result){      
      ...         
      Set&lt;ConstraintViolation&lt;clazz&gt;&gt; constraintViolations=validator.validate((clazz)model);
          for (ConstraintViolation&lt;clazz&gt; constraintViolation : constraintViolations) {
  ...
  }
  </code></pre>
  
  <p>My code is not correct, since a get the error:</p>
  
  <blockquote>
    <p>clazz cannot be resolved to a type</p>
  </blockquote>
  
  <p>How should I edit my code in order to be able to pass to this method any Class I want?</p>
  
  <p>Thank you</p>