From bbf61700f00b42853eb36ddf6b8da975faae4542 Mon Sep 17 00:00:00 2001
From: Matthew Swift <matthew.swift@forgerock.com>
Date: Wed, 22 Jun 2016 17:31:07 +0000
Subject: [PATCH] Minor code cleanup

---
 opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Utils.java |   40 ++--------------------------------------
 1 files changed, 2 insertions(+), 38 deletions(-)

diff --git a/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Utils.java b/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Utils.java
index e7d155c..0834f04 100644
--- a/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Utils.java
+++ b/opendj-rest2ldap/src/main/java/org/forgerock/opendj/rest2ldap/Utils.java
@@ -15,7 +15,6 @@
  */
 package org.forgerock.opendj.rest2ldap;
 
-import static org.forgerock.opendj.rest2ldap.Rest2ldapMessages.*;
 import static javax.xml.bind.DatatypeConverter.parseDateTime;
 import static javax.xml.bind.DatatypeConverter.printDateTime;
 import static org.forgerock.opendj.ldap.Filter.alwaysFalse;
@@ -26,6 +25,7 @@
 import static org.forgerock.opendj.ldap.schema.CoreSchema.getBooleanSyntax;
 import static org.forgerock.opendj.ldap.schema.CoreSchema.getGeneralizedTimeSyntax;
 import static org.forgerock.opendj.ldap.schema.CoreSchema.getIntegerSyntax;
+import static org.forgerock.opendj.rest2ldap.Rest2ldapMessages.ERR_UNRECOGNIZED_JSON_VALUE;
 
 import java.io.BufferedReader;
 import java.io.File;
@@ -34,7 +34,6 @@
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
-import java.util.List;
 import java.util.Locale;
 
 import org.forgerock.i18n.LocalizableMessage;
@@ -80,12 +79,6 @@
         }
     }
 
-    static Object attributeToJson(final Attribute a) {
-        final Function<ByteString, Object, NeverThrowsException> f = byteStringToJson(a.getAttributeDescription());
-        final boolean isSingleValued = a.getAttributeDescription().getAttributeType().isSingleValue();
-        return isSingleValued ? a.parse().as(f) : asList(a.parse().asSetOf(f));
-    }
-
     static Function<Object, ByteString, NeverThrowsException> base64ToByteString() {
         return BASE64_TO_BYTESTRING;
     }
@@ -113,24 +106,6 @@
         };
     }
 
-    static <T> T ensureNotNull(final T object) {
-        if (object == null) {
-            throw new NullPointerException();
-        }
-        return object;
-    }
-
-    static <T> T ensureNotNull(final T object, final String message) {
-        if (object == null) {
-            throw new NullPointerException(message);
-        }
-        return object;
-    }
-
-    static String getAttributeName(final Attribute a) {
-        return a.getAttributeDescription().withoutOption("binary").toString();
-    }
-
     /**
      * Stub formatter for i18n strings.
      *
@@ -144,7 +119,7 @@
         return String.format(format, args);
     }
 
-    static boolean isJSONPrimitive(final Object value) {
+    private static boolean isJSONPrimitive(final Object value) {
         return value instanceof String || value instanceof Boolean || value instanceof Number;
     }
 
@@ -152,10 +127,6 @@
         return v == null || v.isNull() || (v.isList() && v.size() == 0);
     }
 
-    static Attribute jsonToAttribute(final Object value, final AttributeDescription ad) {
-        return jsonToAttribute(value, ad, jsonToByteString(ad));
-    }
-
     static Attribute jsonToAttribute(final Object value, final AttributeDescription ad,
             final Function<Object, ByteString, NeverThrowsException> f) {
         if (isJSONPrimitive(value)) {
@@ -242,13 +213,6 @@
         return new BadRequestException(message.toString(), cause);
     }
 
-    private static <T> List<T> asList(final Collection<T> c) {
-        if (c instanceof List) {
-            return (List<T>) c;
-        }
-        return new ArrayList<>(c);
-    }
-
     /** Prevent instantiation. */
     private Utils() {
         // No implementation required.

--
Gitblit v1.10.0