From 6b5f26722aa60b3f428a930e9d7eebce8f514c9d Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Tue, 25 Aug 2015 13:00:27 +0000
Subject: [PATCH] Use Collection.contains()
---
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java | 12 +----
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/EntryContainer.java | 19 ++-------
opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java | 19 ++-------
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VLVIndex.java | 12 +----
opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java | 6 +--
5 files changed, 18 insertions(+), 50 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/EntryContainer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/EntryContainer.java
index 215c9e3..ee182b5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/EntryContainer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/EntryContainer.java
@@ -3265,30 +3265,21 @@
private boolean isAttributeModified(AttributeIndex index,
List<Modification> mods)
{
- boolean attributeModified = false;
AttributeType indexAttributeType = index.getAttributeType();
- Iterable<AttributeType> subTypes =
+ List<AttributeType> subTypes =
DirectoryServer.getSchema().getSubTypes(indexAttributeType);
for (Modification mod : mods)
{
Attribute modAttr = mod.getAttribute();
AttributeType modAttrType = modAttr.getAttributeType();
- if (modAttrType.equals(indexAttributeType))
+ if (modAttrType.equals(indexAttributeType)
+ || subTypes.contains(modAttrType))
{
- attributeModified = true;
- break;
- }
- for(AttributeType subType : subTypes)
- {
- if(modAttrType.equals(subType))
- {
- attributeModified = true;
- break;
- }
+ return true;
}
}
- return attributeModified;
+ return false;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VLVIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VLVIndex.java
index fd72593..c6fc769 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VLVIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VLVIndex.java
@@ -377,21 +377,15 @@
for (SortKey sortKey : sortOrder.getSortKeys())
{
AttributeType attributeType = sortKey.getAttributeType();
- Iterable<AttributeType> subTypes = DirectoryServer.getSchema().getSubTypes(attributeType);
+ List<AttributeType> subTypes = DirectoryServer.getSchema().getSubTypes(attributeType);
for (Modification mod : mods)
{
AttributeType modAttrType = mod.getAttribute().getAttributeType();
- if (modAttrType.equals(attributeType))
+ if (modAttrType.equals(attributeType)
+ || subTypes.contains(modAttrType))
{
return true;
}
- for (AttributeType subType : subTypes)
- {
- if (modAttrType.equals(subType))
- {
- return true;
- }
- }
}
}
return false;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
index 289e0bc..cfb72bc 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/EntryContainer.java
@@ -2865,30 +2865,21 @@
*/
private static boolean isAttributeModified(AttributeIndex index, List<Modification> mods)
{
- boolean attributeModified = false;
AttributeType indexAttributeType = index.getAttributeType();
- Iterable<AttributeType> subTypes =
+ List<AttributeType> subTypes =
DirectoryServer.getSchema().getSubTypes(indexAttributeType);
for (Modification mod : mods)
{
Attribute modAttr = mod.getAttribute();
AttributeType modAttrType = modAttr.getAttributeType();
- if (modAttrType.equals(indexAttributeType))
+ if (modAttrType.equals(indexAttributeType)
+ || subTypes.contains(modAttrType))
{
- attributeModified = true;
- break;
- }
- for(AttributeType subType : subTypes)
- {
- if(modAttrType.equals(subType))
- {
- attributeModified = true;
- break;
- }
+ return true;
}
}
- return attributeModified;
+ return false;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
index abe553b..bdbc409 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/pluggable/VLVIndex.java
@@ -400,21 +400,15 @@
for (final SortKey sortKey : sortOrder.getSortKeys())
{
final AttributeType attributeType = sortKey.getAttributeType();
- final Iterable<AttributeType> subTypes = DirectoryServer.getSchema().getSubTypes(attributeType);
+ final List<AttributeType> subTypes = DirectoryServer.getSchema().getSubTypes(attributeType);
for (final Modification mod : mods)
{
final AttributeType modAttrType = mod.getAttribute().getAttributeType();
- if (modAttrType.equals(attributeType))
+ if (modAttrType.equals(attributeType)
+ || subTypes.contains(modAttrType))
{
return true;
}
- for (final AttributeType subType : subTypes)
- {
- if (modAttrType.equals(subType))
- {
- return true;
- }
- }
}
}
return false;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java b/opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java
index 6b3d255..89e4e2a 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/types/Schema.java
@@ -439,11 +439,9 @@
* type, or an empty set if there are no subtypes
* registered for the attribute type.
*/
- public Iterable<AttributeType>
- getSubTypes(AttributeType attributeType)
+ public List<AttributeType> getSubTypes(AttributeType attributeType)
{
- List<AttributeType> subTypes =
- subordinateTypes.get(attributeType);
+ List<AttributeType> subTypes = subordinateTypes.get(attributeType);
if (subTypes == null)
{
return Collections.emptyList();
--
Gitblit v1.10.0