package com.github.valdr;

import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import lombok.Getter;
import org.hibernate.validator.constraints.Email;

import javax.validation.constraints.Digits;
import javax.validation.constraints.Future;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Past;
import javax.validation.constraints.Pattern;
import javax.validation.constraints.Size;
import java.lang.annotation.Annotation;
import java.util.Arrays;

public enum SupportedValidator {

  REQUIRED("required", NotNull.class), MIN("min", Min.class), MAX("max", Max.class), SIZE("size", Size.class),
  DIGITS("digits", Digits.class), PATTERN("pattern", Pattern.class), FUTURE("future", Future.class), PAST("past",
    Past.class), EMAIL("hibernateEmail", Email.class), URL("hibernateUrl", org.hibernate.validator.constraints.URL
    .class);

  @Getter
  private final Class<? extends Annotation> beanValidationAnnotation;
  private final String camelCaseName;

  private SupportedValidator(String camelCaseName, Class<? extends Annotation> beanValidationAnnotation) {
    this.camelCaseName = camelCaseName;
    this.beanValidationAnnotation = beanValidationAnnotation;
  }

  @Override
  public String toString() {
    return camelCaseName;
  }

  public static Iterable<Class<? extends Annotation>> getAllBeanValidationAnnotations() {
    return Iterables.transform(Arrays.asList(values()), new Function<SupportedValidator,
      Class<? extends Annotation>>() {

      @Override
      public Class<? extends Annotation> apply(SupportedValidator input) {
        if (input == null) {
          throw new NullPointerException("Passed validator must not be null.");
        }
        return input.getBeanValidationAnnotation();
      }
    });
  }

  public static SupportedValidator valueOfAnnotationClassOrNull(Class<? extends Annotation> beanValidationAnnotation) {
    for (SupportedValidator supportedValidator : values()) {
      if (supportedValidator.getBeanValidationAnnotation().equals(beanValidationAnnotation)) {
        return supportedValidator;
      }
    }
    return null;
  }
}

@@ -587,16 +587,279 @@
 rrays;%0A%0A
+/**%0A * All validators currently supported by valdr Bean Validation. Each value represents a validator that valdr provides%0A * an implementation for (JavaScript). The %7B@code toString()%7D method is guaranteed to return the validator name as%0A * expected by valdr.%0A */%0A
 public e
@@ -884,16 +884,36 @@
 ator %7B%0A%0A
+  // CHECKSTYLE:OFF%0A
   REQUIR
@@ -1256,16 +1256,35 @@
 .class);
+%0A  // CHECKSTYLE:ON
 %0A%0A  @Get
@@ -1678,24 +1678,170 @@
 eName;%0A  %7D%0A%0A
+  /**%0A   * Iterates over all the enum values and collects their annotation class member.%0A   *%0A   * @return all collected annotation classes%0A   */%0A
   public sta
@@ -2330,16 +2330,231 @@
 );%0A  %7D%0A%0A
+  /**%0A   * Finds enum value whose annotation class member matches the method argument.%0A   *%0A   * @param beanValidationAnnotation annotation class%0A   * @return enum value matching the passed annotation or null%0A   */%0A
   public

Add Javadoc.