]> WPIA git - gigi.git/commitdiff
UPD: transform group into an Enum
authorFelix Dörre <felix@dogcraft.de>
Thu, 15 Jan 2015 22:26:05 +0000 (23:26 +0100)
committerJanis Streib <janis@dogcraft.de>
Wed, 21 Jan 2015 00:28:16 +0000 (01:28 +0100)
src/org/cacert/gigi/dbObjects/Group.java

index 69f8e40bf7434422bf56a957ffaceec528a0601a..385e3ecbea472fc35c30dcd183605b2cb294a138 100644 (file)
@@ -1,14 +1,11 @@
 package org.cacert.gigi.dbObjects;
 
-import java.util.HashMap;
-
 import org.cacert.gigi.database.DatabaseConnection;
 import org.cacert.gigi.database.GigiPreparedStatement;
 import org.cacert.gigi.database.GigiResultSet;
 
-public class Group {
-
-    private static HashMap<String, Group> cache = new HashMap<>();
+public enum Group {
+    SUPPORTER("supporter"), ARBITRATOR("arbitrator"), BLOCKEDASSURER("blockedassurer"), BLOCKEDLOGIN("blockedlogin"), TTP_ASSURER("ttp-assurer"), TTP_APPLICANT("ttp-applicant"), CODESIGNING("codesigning"), ORGASSURER("orgassurer");
 
     private final String dbName;
 
@@ -16,43 +13,8 @@ public class Group {
         dbName = name;
     }
 
-    @Override
-    public int hashCode() {
-        final int prime = 31;
-        int result = 1;
-        result = prime * result + ((dbName == null) ? 0 : dbName.hashCode());
-        return result;
-    }
-
-    @Override
-    public boolean equals(Object obj) {
-        if (this == obj) {
-            return true;
-        }
-        if (obj == null) {
-            return false;
-        }
-        if (getClass() != obj.getClass()) {
-            return false;
-        }
-        Group other = (Group) obj;
-        if (dbName == null) {
-            if (other.dbName != null) {
-                return false;
-            }
-        } else if ( !dbName.equals(other.dbName)) {
-            return false;
-        }
-        return true;
-    }
-
-    public static synchronized Group getByString(String name) {
-        Group g = cache.get(name);
-        if (g == null) {
-            g = new Group(name);
-            cache.put(name, g);
-        }
-        return g;
+    public static Group getByString(String name) {
+        return valueOf(name.toUpperCase().replace('-', '_'));
     }
 
     public String getDatabaseName() {