]> source.dussan.org Git - sonarqube.git/commitdiff
fix minor flaws in Characteristic class
authorSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 15 Jun 2015 12:36:15 +0000 (14:36 +0200)
committerSébastien Lesaint <sebastien.lesaint@sonarsource.com>
Mon, 15 Jun 2015 17:04:10 +0000 (19:04 +0200)
server/sonar-server/src/main/java/org/sonar/server/computation/debt/Characteristic.java
server/sonar-server/src/test/java/org/sonar/server/computation/debt/CharacteristicTest.java

index 53b79803ee67e37f8c1717caf1bb85c29e8963f9..5c1224c8df9f1441876de00172f0447a75a9e66e 100644 (file)
 
 package org.sonar.server.computation.debt;
 
+import javax.annotation.Nullable;
 import javax.annotation.concurrent.Immutable;
 
 import static java.util.Objects.requireNonNull;
 
 @Immutable
 public class Characteristic {
-
   private final int id;
   private final String key;
 
@@ -45,7 +45,7 @@ public class Characteristic {
   }
 
   @Override
-  public boolean equals(Object o) {
+  public boolean equals(@Nullable Object o) {
     if (this == o) {
       return true;
     }
@@ -54,12 +54,7 @@ public class Characteristic {
     }
 
     Characteristic that = (Characteristic) o;
-
-    if (id != that.id) {
-      return false;
-    }
-    return key.equals(that.key);
-
+    return id == that.id && key.equals(that.key);
   }
 
   @Override
@@ -71,7 +66,7 @@ public class Characteristic {
 
   @Override
   public String toString() {
-    return "CharacteristicImpl{" +
+    return "Characteristic{" +
       "id=" + id +
       ", key='" + key + '\'' +
       '}';
index 1d58bcc0906d266d80d10b2f6d071d96a45ad0a5..1499001ec1d63ffb5f013f67eca6a2d187cfb9cd 100644 (file)
@@ -40,7 +40,7 @@ public class CharacteristicTest {
 
   @Test
   public void test_to_string() throws Exception {
-    assertThat(new Characteristic(1, "PORTABILITY").toString()).isEqualTo("CharacteristicImpl{id=1, key='PORTABILITY'}");
+    assertThat(new Characteristic(1, "PORTABILITY").toString()).isEqualTo("Characteristic{id=1, key='PORTABILITY'}");
   }
 
   @Test