From f0c7d2dd4fa25e1b91f576a75b61488ce2a4fa30 Mon Sep 17 00:00:00 2001
From: Nicolas Capponi <nicolas.capponi@forgerock.com>
Date: Wed, 05 Nov 2014 16:25:14 +0000
Subject: [PATCH] OPENDJ-1581 CR-5092 Move UNDEFINED_ASSERTION and DEFAULT_COMPARATOR  constants from AbstractMatchingRuleImpl to Assertion interface

---
 opendj-core/src/main/java/org/forgerock/opendj/ldap/Assertion.java                       |   27 +++++++++++++++++++++++++++
 opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java |   24 ++----------------------
 2 files changed, 29 insertions(+), 22 deletions(-)

diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/Assertion.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/Assertion.java
index 59ebf9a..cfd6747 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/Assertion.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/Assertion.java
@@ -26,6 +26,9 @@
  */
 package org.forgerock.opendj.ldap;
 
+
+import java.util.Comparator;
+
 import org.forgerock.opendj.ldap.spi.IndexQueryFactory;
 
 /**
@@ -33,6 +36,29 @@
  */
 public interface Assertion {
 
+    /** An assertion that always return UNDEFINED for matches and that creates a match all query. */
+    public static final Assertion UNDEFINED_ASSERTION = new Assertion() {
+        @Override
+        public ConditionResult matches(final ByteSequence normalizedAttributeValue) {
+            return ConditionResult.UNDEFINED;
+        }
+
+        @Override
+        public <T> T createIndexQuery(IndexQueryFactory<T> factory) throws DecodeException {
+            // Subclassing this class will always work, albeit inefficiently.
+            // This is better than throwing an exception for no good reason.
+            return factory.createMatchAllQuery();
+        }
+    };
+
+    /** A default ByteSequence comparator. */
+    public static final Comparator<ByteSequence> DEFAULT_COMPARATOR = new Comparator<ByteSequence>() {
+        @Override
+        public int compare(final ByteSequence o1, final ByteSequence o2) {
+            return o1.compareTo(o2);
+        }
+    };
+
     /**
      * Indicates whether the provided attribute value should be considered a
      * match for this assertion value according to the matching rule.
@@ -60,4 +86,5 @@
      *           If an error occurs while generating the index query.
      */
     <T> T createIndexQuery(IndexQueryFactory<T> factory) throws DecodeException;
+
 }
diff --git a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java
index 5a159f3..da18e26 100644
--- a/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java
+++ b/opendj-core/src/main/java/org/forgerock/opendj/ldap/schema/AbstractMatchingRuleImpl.java
@@ -39,6 +39,8 @@
 import org.forgerock.opendj.ldap.spi.Indexer;
 import org.forgerock.opendj.ldap.spi.IndexingOptions;
 
+import static org.forgerock.opendj.ldap.Assertion.*;
+
 /**
  * This class implements a default equality or approximate matching rule that
  * matches normalized values in byte order.
@@ -98,28 +100,6 @@
         }
     }
 
-    private static final Assertion UNDEFINED_ASSERTION = new Assertion() {
-        @Override
-        public ConditionResult matches(final ByteSequence normalizedAttributeValue) {
-            return ConditionResult.UNDEFINED;
-        }
-
-        @Override
-        public <T> T createIndexQuery(IndexQueryFactory<T> factory) throws DecodeException {
-            // Subclassing this class will always work, albeit inefficiently.
-            // This is better than throwing an exception for no good reason.
-            return factory.createMatchAllQuery();
-        }
-    };
-
-    private static final Comparator<ByteSequence> DEFAULT_COMPARATOR =
-            new Comparator<ByteSequence>() {
-                @Override
-                public int compare(final ByteSequence o1, final ByteSequence o2) {
-                    return o1.compareTo(o2);
-                }
-            };
-
     AbstractMatchingRuleImpl() {
         // Nothing to do.
     }

--
Gitblit v1.10.0