code: public static <T, X extends Exception> T validate(T o, Matcher<?> matcher, X exception) throws X {
      if (!matcher.matches(o)) {
        throw exception;
      }
      return o;
    }
docs: Validate the given object that is supposed to satisfy the matcher.
  If not, a recoverable exception will be thrown that the client
  is supposed to catch and recover from.
  
  @param <T> type of object to validate
  @param <X> type of exception to throw if validation fails
  @param o the object to validate
  @param matcher the matcher that the object must satisfy
  @param exception the recoverable exception to be thrown if validation fails.
  @return the validated object, if valid
  @throws X the recoverable exception, if validation fails