From db786032bf45be89c4a893281911364d158cfb6e Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Sat, 20 Oct 2012 10:10:53 +0000
Subject: [PATCH] Update to use new json-resource 2.0 APIs.

---
 opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Utils.java |   56 ++++++++++++++++++++++++++++----------------------------
 1 files changed, 28 insertions(+), 28 deletions(-)

diff --git a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Utils.java b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Utils.java
index 2446095..df1bb12 100644
--- a/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Utils.java
+++ b/opendj3/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Utils.java
@@ -41,7 +41,8 @@
     private static final Function<ByteString, Object, Attribute> BYTESTRING_TO_JSON =
             new Function<ByteString, Object, Attribute>() {
                 public Object apply(final ByteString value, final Attribute a) {
-                    Syntax syntax = a.getAttributeDescription().getAttributeType().getSyntax();
+                    final Syntax syntax =
+                            a.getAttributeDescription().getAttributeType().getSyntax();
                     if (syntax.equals(getBooleanSyntax())) {
                         return Functions.byteStringToBoolean().apply(value, null);
                     } else if (syntax.equals(getIntegerSyntax())) {
@@ -58,39 +59,17 @@
                 }
             };
 
-    // Prevent instantiation.
-    private Utils() {
-        // No implementation required.
-    }
-
-    private static <T> List<T> asList(Collection<T> c) {
-        if (c instanceof List) {
-            return (List<T>) c;
-        } else {
-            List<T> result = new ArrayList<T>(c.size());
-            result.addAll(c);
-            return result;
-        }
+    static Object attributeToJson(final Attribute a) {
+        final Function<ByteString, Object, Void> f = Functions.fixedFunction(BYTESTRING_TO_JSON, a);
+        final boolean isSingleValued =
+                a.getAttributeDescription().getAttributeType().isSingleValue();
+        return isSingleValued ? a.parse().as(f) : asList(a.parse().asSetOf(f));
     }
 
     static Function<ByteString, Object, Attribute> byteStringToJson() {
         return BYTESTRING_TO_JSON;
     }
 
-    static Object attributeToJson(Attribute a) {
-        Function<ByteString, Object, Void> f = Functions.fixedFunction(BYTESTRING_TO_JSON, a);
-        boolean isSingleValued = a.getAttributeDescription().getAttributeType().isSingleValue();
-        return isSingleValued ? a.parse().as(f) : asList(a.parse().asSetOf(f));
-    }
-
-    static String getAttributeName(Attribute a) {
-        return a.getAttributeDescription().withoutOption("binary").toString();
-    }
-
-    static String toLowerCase(String s) {
-        return s != null ? s.toLowerCase(Locale.ENGLISH) : null;
-    }
-
     static <T> T ensureNotNull(final T object) {
         if (object == null) {
             throw new NullPointerException();
@@ -105,4 +84,25 @@
         return object;
     }
 
+    static String getAttributeName(final Attribute a) {
+        return a.getAttributeDescription().withoutOption("binary").toString();
+    }
+
+    static String toLowerCase(final String s) {
+        return s != null ? s.toLowerCase(Locale.ENGLISH) : null;
+    }
+
+    private static <T> List<T> asList(final Collection<T> c) {
+        if (c instanceof List) {
+            return (List<T>) c;
+        } else {
+            return new ArrayList<T>(c);
+        }
+    }
+
+    // Prevent instantiation.
+    private Utils() {
+        // No implementation required.
+    }
+
 }

--
Gitblit v1.10.0