bval-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mben...@apache.org
Subject svn commit: r1386678 - /bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidationProvider.java
Date Mon, 17 Sep 2012 15:56:56 GMT
Author: mbenson
Date: Mon Sep 17 15:56:56 2012
New Revision: 1386678

URL: http://svn.apache.org/viewvc?rev=1386678&view=rev
Log:
code audit: formatting, type-safety, class comparison using .equals instead of == to avoid
potential classloader oddities

Modified:
    bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidationProvider.java

Modified: bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidationProvider.java
URL: http://svn.apache.org/viewvc/bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidationProvider.java?rev=1386678&r1=1386677&r2=1386678&view=diff
==============================================================================
--- bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidationProvider.java
(original)
+++ bval/trunk/bval-jsr303/src/main/java/org/apache/bval/jsr303/ApacheValidationProvider.java
Mon Sep 17 15:56:56 2012
@@ -49,7 +49,7 @@ public class ApacheValidationProvider im
      * @return boolean suitability
      */
     public boolean isSuitable(Class<? extends Configuration<?>> builderClass)
{
-        return ApacheValidatorConfiguration.class == builderClass;
+        return ApacheValidatorConfiguration.class.equals(builderClass);
     }
 
     /**
@@ -72,20 +72,17 @@ public class ApacheValidationProvider im
      * @throws javax.validation.ValidationException
      *             if the ValidatorFactory cannot be built
      */
-    @SuppressWarnings("unchecked")
     public ValidatorFactory buildValidatorFactory(final ConfigurationState configuration)
{
         final Class<? extends ValidatorFactory> validatorFactoryClass;
         try {
             String validatorFactoryClassname =
                 configuration.getProperties().get(ApacheValidatorConfiguration.Properties.VALIDATOR_FACTORY_CLASSNAME);
 
-            if (validatorFactoryClassname == null)
+            if (validatorFactoryClassname == null) {
                 validatorFactoryClass = ApacheValidatorFactory.class;
-            else
-            {
-                validatorFactoryClass
-                  = (Class<? extends ValidatorFactory>) ClassUtils.getClass(validatorFactoryClassname);
-                validatorFactoryClass.asSubclass(ValidatorFactory.class);
+            } else {
+                validatorFactoryClass =
+                    ClassUtils.getClass(validatorFactoryClassname).asSubclass(ValidatorFactory.class);
             }
         } catch (ValidationException ex) {
             throw ex;
@@ -103,28 +100,21 @@ public class ApacheValidationProvider im
         // because the classloader of ApacheValidationProvider will always
         // be an ancestor of the loader of validatorFactoryClass.
         return (System.getSecurityManager() == null)
-            ? instantiateValidatorFactory(validatorFactoryClass, configuration)
-            : AccessController.doPrivileged(new PrivilegedAction<ValidatorFactory>()
{
-                  public ValidatorFactory run() {
-                      return instantiateValidatorFactory(validatorFactoryClass, configuration);
-                  }
-              });
+            ? instantiateValidatorFactory(validatorFactoryClass, configuration) : AccessController
+                .doPrivileged(new PrivilegedAction<ValidatorFactory>() {
+                    public ValidatorFactory run() {
+                        return instantiateValidatorFactory(validatorFactoryClass, configuration);
+                    }
+                });
     }
 
-
-
     private static ValidatorFactory instantiateValidatorFactory(
-        final Class<? extends ValidatorFactory> validatorFactoryClass,
-        final ConfigurationState                configuration
-    ) {
-      try
-      {
-          return validatorFactoryClass.getConstructor(ConfigurationState.class).newInstance(configuration);
-      }
-      catch (final Exception ex)
-      {
-          throw new ValidationException("Cannot instantiate : " + validatorFactoryClass,
ex);
-      }
+        final Class<? extends ValidatorFactory> validatorFactoryClass, final ConfigurationState
configuration) {
+        try {
+            return validatorFactoryClass.getConstructor(ConfigurationState.class).newInstance(configuration);
+        } catch (final Exception ex) {
+            throw new ValidationException("Cannot instantiate : " + validatorFactoryClass,
ex);
+        }
     }
 
 }



Mime
View raw message