Replaced all tabs with spaces in java and pom.xml
[so.git] / common / src / main / java / org / onap / so / openpojo / rules / HasEqualsAndHashCodeRule.java
index 0c7d6ad..351c5b0 100644 (file)
@@ -22,12 +22,9 @@ package org.onap.so.openpojo.rules;
 
 import static org.hamcrest.CoreMatchers.anyOf;
 import static org.hamcrest.CoreMatchers.anything;
-
 import java.lang.reflect.Method;
 import java.lang.reflect.Parameter;
-
 import org.hamcrest.Matcher;
-
 import com.openpojo.reflection.PojoClass;
 import com.openpojo.validation.affirm.Affirm;
 import com.openpojo.validation.rule.Rule;
@@ -37,45 +34,46 @@ import com.openpojo.validation.rule.Rule;
  */
 public class HasEqualsAndHashCodeRule implements Rule {
 
-       private final Matcher m;
-       public HasEqualsAndHashCodeRule() {
-               m = anything();
-       }
-       
-       public HasEqualsAndHashCodeRule(Matcher m) {
-               this.m = m;
-       }
-       @Override
-       public void evaluate(PojoClass pojoClass) {
-               Class<?> clazz = pojoClass.getClazz();
-               if (anyOf(m).matches(clazz)) { 
-                       boolean hasEquals = false;
-                       boolean hasHashCode = false;
-                       final String name = clazz.getSimpleName();
-                       final Method[] methods;
-                       if (clazz.getSuperclass().equals(Object.class)) {
-                               methods = clazz.getDeclaredMethods();
-                       } else {
-                               methods = clazz.getMethods();
-                       }
-                       for (Method method : methods) {
-                               Parameter[] parameters = method.getParameters();
-                               if ("equals".equals(method.getName()) && boolean.class.equals(method.getReturnType()) && parameters.length == 1 && Object.class.equals(parameters[0].getType())) {
-                                       hasEquals = true;
-                               } else if ("hashCode".equals(method.getName()) && int.class.equals(method.getReturnType())) {
-                                       hasHashCode = true;
-                               }
-                       }
-                       
-                       if (!hasEquals) {
-                               Affirm.fail(String.format(
-                                               "[%s] does not override equals", name));
-                       }
-                       if (!hasHashCode) {
-                               Affirm.fail(String.format(
-                                               "[%s] does not override hashCode", name));
-                       }
-               }
-       }
+    private final Matcher m;
+
+    public HasEqualsAndHashCodeRule() {
+        m = anything();
+    }
+
+    public HasEqualsAndHashCodeRule(Matcher m) {
+        this.m = m;
+    }
+
+    @Override
+    public void evaluate(PojoClass pojoClass) {
+        Class<?> clazz = pojoClass.getClazz();
+        if (anyOf(m).matches(clazz)) {
+            boolean hasEquals = false;
+            boolean hasHashCode = false;
+            final String name = clazz.getSimpleName();
+            final Method[] methods;
+            if (clazz.getSuperclass().equals(Object.class)) {
+                methods = clazz.getDeclaredMethods();
+            } else {
+                methods = clazz.getMethods();
+            }
+            for (Method method : methods) {
+                Parameter[] parameters = method.getParameters();
+                if ("equals".equals(method.getName()) && boolean.class.equals(method.getReturnType())
+                        && parameters.length == 1 && Object.class.equals(parameters[0].getType())) {
+                    hasEquals = true;
+                } else if ("hashCode".equals(method.getName()) && int.class.equals(method.getReturnType())) {
+                    hasHashCode = true;
+                }
+            }
+
+            if (!hasEquals) {
+                Affirm.fail(String.format("[%s] does not override equals", name));
+            }
+            if (!hasHashCode) {
+                Affirm.fail(String.format("[%s] does not override hashCode", name));
+            }
+        }
+    }
 
 }