From 09fcb137f6d46e0c32f03b0313ac445a2ee7ecc3 Mon Sep 17 00:00:00 2001
From: matthew_swift <matthew_swift@localhost>
Date: Mon, 25 Sep 2006 09:03:39 +0000
Subject: [PATCH] Implement test suite for org.opends.server.types.AttributeType and make it immutable (it's still not 100% immutable - the constructors do not perform deep copies of the extra properties).

---
 opends/src/server/org/opends/server/core/DirectoryServer.java |   25 ++++++-------------------
 1 files changed, 6 insertions(+), 19 deletions(-)

diff --git a/opends/src/server/org/opends/server/core/DirectoryServer.java b/opends/src/server/org/opends/server/core/DirectoryServer.java
index 36b23e3..4dfa929 100644
--- a/opends/src/server/org/opends/server/core/DirectoryServer.java
+++ b/opends/src/server/org/opends/server/core/DirectoryServer.java
@@ -29,6 +29,7 @@
 
 import java.net.InetAddress;
 import java.util.ArrayList;
+import java.util.Collections;
 import java.util.LinkedHashMap;
 import java.util.LinkedHashSet;
 import java.util.Properties;
@@ -3078,10 +3079,6 @@
 
       if (directoryServer.objectClassAttributeType == null)
       {
-        ConcurrentHashMap<String,String> typeNames =
-             new ConcurrentHashMap<String,String>();
-        typeNames.put(OBJECTCLASS_ATTRIBUTE_TYPE_NAME, "objectClass");
-
         AttributeSyntax oidSyntax =
              directoryServer.schema.getSyntax(SYNTAX_OID_NAME);
         if (oidSyntax == null)
@@ -3099,7 +3096,8 @@
         }
 
         directoryServer.objectClassAttributeType =
-             new AttributeType("objectClass", typeNames,
+             new AttributeType("objectClass",
+                               Collections.singleton("objectClass"),
                                OBJECTCLASS_ATTRIBUTE_TYPE_OID, null, null,
                                oidSyntax, AttributeUsage.USER_APPLICATIONS,
                                false, false, false, false);
@@ -3137,15 +3135,7 @@
                       String.valueOf(name));
 
 
-    String lowerName = toLowerCase(name);
-    ConcurrentHashMap<String,String> names =
-         new ConcurrentHashMap<String,String>(1);
-    names.put(lowerName, name);
-
-    return new AttributeType(name, names, lowerName, null, null,
-                             getDefaultAttributeSyntax(),
-                             AttributeUsage.USER_APPLICATIONS, false, false,
-                             false, false);
+    return getDefaultAttributeType(name, getDefaultAttributeSyntax());
   }
 
 
@@ -3169,11 +3159,8 @@
 
 
     String lowerName = toLowerCase(name);
-    ConcurrentHashMap<String,String> names =
-         new ConcurrentHashMap<String,String>(1);
-    names.put(lowerName, name);
-
-    return new AttributeType(name, names, lowerName, null, null, syntax,
+    return new AttributeType(name, Collections.singleton(name),
+                             lowerName, null, null, syntax,
                              AttributeUsage.USER_APPLICATIONS, false, false,
                              false, false);
   }

--
Gitblit v1.10.0