From edc595e56216e680d268376e85c7625f2f052b6a Mon Sep 17 00:00:00 2001
From: Jean-Noel Rouvignac <jean-noel.rouvignac@forgerock.com>
Date: Thu, 09 Jul 2015 08:40:36 +0000
Subject: [PATCH] AutoRefactor'ed Collections
---
opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ReplSessionSecurity.java | 6
opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/ChangeNumberIndexer.java | 2
opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VerifyJob.java | 8
opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java | 11
opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java | 2
opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java | 2
opendj-server-legacy/src/main/java/org/opends/server/extensions/RandomPasswordGenerator.java | 6
opendj-server-legacy/src/main/java/org/opends/server/extensions/SimilarityBasedPasswordValidator.java | 4
opendj-server-legacy/src/test/java/org/opends/server/extensions/TLSByteChannelTestCase.java | 6
opendj-server-legacy/src/main/java/org/opends/server/tools/JavaPropertiesToolArgumentParser.java | 2
opendj-server-legacy/src/test/java/org/opends/server/api/plugin/DirectoryServerPluginTestCase.java | 29 --
opendj-server-legacy/src/main/java/org/opends/server/admin/ManagedObjectPath.java | 5
opendj-server-legacy/src/main/java/org/opends/server/plugins/AttributeCleanupPlugin.java | 18 -
opendj-server-legacy/src/test/java/org/opends/server/admin/TestTopCfgDefnTest.java | 91 +-------
opendj-server-legacy/src/test/java/org/opends/server/util/TestStaticUtils.java | 4
opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ModifyCommonMsg.java | 2
opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java | 4
opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java | 2
opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java | 21 --
opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java | 5
opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPFilter.java | 19 +
opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java | 2
opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServerDomain.java | 2
opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java | 6
opendj-server-legacy/src/test/java/org/opends/server/replication/server/AssuredReplicationServerTest.java | 4
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java | 2
opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java | 6
opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTests.java | 5
opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/Uninstaller.java | 17
opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java | 22 +-
opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/JavaArgumentsDialog.java | 2
opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java | 38 +--
opendj-server-legacy/src/main/java/org/opends/server/extensions/DiskSpaceMonitor.java | 2
opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java | 23 --
opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java | 5
opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java | 2
opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java | 12
opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java | 2
opendj-server-legacy/src/test/java/org/opends/server/crypto/GetSymmetricKeyExtendedOperationTestCase.java | 2
opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/UninstallCliHelper.java | 12
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java | 6
opendj-server-legacy/src/main/java/org/opends/server/extensions/TraditionalWorkQueue.java | 2
opendj-server-legacy/src/main/java/org/opends/server/extensions/JMXAlertHandler.java | 11
opendj-server-legacy/src/main/java/org/opends/server/extensions/ParallelWorkQueue.java | 2
opendj-server-legacy/src/test/java/org/opends/server/crypto/CryptoManagerTestCase.java | 2
opendj-server-legacy/src/main/java/org/opends/server/controls/ServerSideSortRequestControl.java | 2
opendj-server-legacy/src/test/java/org/opends/server/admin/server/AggregationServerTest.java | 5
opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java | 3
opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContextHelper.java | 3
opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java | 2
opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskClient.java | 6
opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java | 23 -
opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java | 3
opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java | 2
opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/SecurityOptionsDialog.java | 6
opendj-server-legacy/src/main/java/org/opends/server/replication/server/SafeReadExpectedAcksInfo.java | 2
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java | 2
opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java | 25 --
opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java | 3
opendj-server-legacy/src/test/java/org/opends/server/tools/UpgradeTestCase.java | 10
opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java | 6
opendj-server-legacy/src/main/java/org/opends/server/util/VersionCompatibilityIssue.java | 4
opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java | 2
opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java | 2
opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java | 4
65 files changed, 175 insertions(+), 378 deletions(-)
diff --git a/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContextHelper.java b/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContextHelper.java
index 0f1ae75..9bb01b5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContextHelper.java
+++ b/opendj-server-legacy/src/main/java/org/opends/admin/ads/ADSContextHelper.java
@@ -116,9 +116,8 @@
suffixes = new TreeSet<>();
}
DN newDN = DN.valueOf(ADSContext.getAdministrationSuffixDN());
- if (!suffixes.contains(newDN))
+ if (suffixes.add(newDN))
{
- suffixes.add(newDN);
backend.setBaseDN(suffixes);
backend.commit();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java
index 35fa724..396dee8 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/DeleteBaseDNPanel.java
@@ -36,6 +36,7 @@
import java.awt.event.ActionListener;
import java.util.ArrayList;
import java.util.Collection;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
@@ -169,10 +170,7 @@
Set<Object> selected = new HashSet<>();
if (s != null)
{
- for (Object o : s)
- {
- selected.add(o);
- }
+ Collections.addAll(selected, s);
}
final DefaultListModel model = (DefaultListModel)list.getModel();
model.clear();
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
index 15e66be..ea1af28 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/ui/JavaPropertiesPanel.java
@@ -41,6 +41,7 @@
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
+import java.util.Arrays;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashSet;
@@ -110,10 +111,7 @@
private Set<JavaArgumentsDescriptor> readJavaArguments = new HashSet<>();
private Set<JavaArgumentsDescriptor> currentJavaArguments = new HashSet<>();
- private Set<String> allScriptNames = new HashSet<>();
- {
- String[] names =
- {
+ private Set<String> allScriptNames = new HashSet<>(Arrays.asList(
"start-ds", "import-ldif.offline", "backup.online", "base64",
"create-rc-script", "dsconfig", "dsreplication",
"export-ldif.online", "import-ldif.online", "ldapcompare",
@@ -124,27 +122,14 @@
"ldif-diff", "ldifmodify", "ldifsearch", "make-ldif",
"rebuild-index", "restore.offline", "upgrade",
"verify-index", "dbtest"
- };
- for (String name : names)
- {
- allScriptNames.add(name);
- }
- }
+ ));
- private Set<String> relevantScriptNames = new HashSet<>();
- {
- String[] relevantNames =
- {
+ private Set<String> relevantScriptNames = new HashSet<>(Arrays.asList(
"start-ds", "import-ldif.offline", "backup.offline",
"export-ldif.offline",
"ldif-diff", "make-ldif", "rebuild-index", "restore.offline",
"verify-index", "dbtest"
- };
- for (String name : relevantNames)
- {
- relevantScriptNames.add(name);
- }
- }
+ ));
private String readJavaHome;
private boolean readUseOpenDSJavaHome;
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
index 11819c2..93d4cd2 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/ConfigFromFile.java
@@ -126,7 +126,7 @@
errors.add(new OfflineUpdateException(ERR_READING_CONFIG_LDAP.get(t.getMessage()), t));
}
- if (errors.size() > 0 && environmentSettingException != null)
+ if (!errors.isEmpty() && environmentSettingException != null)
{
errors.add(0, environmentSettingException);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
index 7b0cd5e..53ff2de 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/controlpanel/util/Utilities.java
@@ -2481,7 +2481,7 @@
if (sr != null)
{
List<Object> values = sr.getAttributeValues(attrName);
- if (values != null && values.size() > 0)
+ if (values != null && !values.isEmpty())
{
Object o = values.iterator().next();
try
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/UninstallCliHelper.java b/opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/UninstallCliHelper.java
index 4e732e9..1227d5c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/UninstallCliHelper.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/UninstallCliHelper.java
@@ -419,8 +419,8 @@
{
for (int i=0; i<msgs.length; i++)
{
- boolean ignore = (i == 6 && outsideDbs.size() == 0) ||
- (i == 7 && outsideLogs.size() == 0);
+ boolean ignore = (i == 6 && outsideDbs.isEmpty())
+ || (i == 7 && outsideLogs.isEmpty());
if (!ignore)
{
answers[i] = askConfirmation(msgs[i], true, logger);
@@ -481,8 +481,8 @@
break;
}
}
- if (userData.getExternalDbsToRemove().size() == 0 &&
- userData.getExternalLogsToRemove().size() == 0 &&
+ if (userData.getExternalDbsToRemove().isEmpty() &&
+ userData.getExternalLogsToRemove().isEmpty() &&
!userData.getRemoveLibrariesAndTools() &&
!userData.getRemoveDatabases() &&
!userData.getRemoveConfigurationAndSchema() &&
@@ -1385,7 +1385,7 @@
}
if (isInteractive())
{
- if (!stopProcessing && exceptionMsgs.size() > 0)
+ if (!stopProcessing && !exceptionMsgs.isEmpty())
{
println();
try
@@ -1412,7 +1412,7 @@
else
{
logger.info(LocalizableMessage.raw("exceptionMsgs: "+exceptionMsgs));
- if (exceptionMsgs.size() > 0)
+ if (!exceptionMsgs.isEmpty())
{
if (parser.isForceOnError())
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/Uninstaller.java b/opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/Uninstaller.java
index 0c63f2f..b4ae244 100644
--- a/opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/Uninstaller.java
+++ b/opendj-server-legacy/src/main/java/org/opends/guitools/uninstaller/Uninstaller.java
@@ -307,8 +307,8 @@
uud.setExternalDbsToRemove(dbs);
uud.setExternalLogsToRemove(logs);
- if (dbs.size() == 0 &&
- logs.size() == 0 &&
+ if (dbs.isEmpty() &&
+ logs.isEmpty() &&
!uud.getRemoveLibrariesAndTools() &&
!uud.getRemoveDatabases() &&
!uud.getRemoveConfigurationAndSchema() &&
@@ -798,7 +798,7 @@
}
Set<String> dbsToDelete = getUninstallUserData().getExternalDbsToRemove();
- if (dbsToDelete.size() > 0) {
+ if (!dbsToDelete.isEmpty()) {
status = UninstallProgressStep.DELETING_EXTERNAL_DATABASE_FILES;
if (displaySeparator && isVerbose()) {
notifyListeners(getTaskSeparator());
@@ -824,9 +824,8 @@
}
}
- Set<String> logsToDelete =
- getUninstallUserData().getExternalLogsToRemove();
- if (logsToDelete.size() > 0) {
+ Set<String> logsToDelete = getUninstallUserData().getExternalLogsToRemove();
+ if (!logsToDelete.isEmpty()) {
status = UninstallProgressStep.DELETING_EXTERNAL_LOG_FILES;
if (displaySeparator && isVerbose()) {
@@ -1689,7 +1688,7 @@
}
exceptionMsgs.add(getMessage(e));
}
- if (!stopProcessing && exceptionMsgs.size() > 0)
+ if (!stopProcessing && !exceptionMsgs.isEmpty())
{
LocalizableMessage confirmationMsg =
ERR_UNINSTALL_READING_REGISTERED_SERVERS_CONFIRM_UPDATE_REMOTE.get(
@@ -2031,7 +2030,7 @@
logger.info(LocalizableMessage.raw("Updating references in replication server on "+
serverDisplay+"."));
replServers.remove(replServer);
- if (replServers.size() > 0)
+ if (!replServers.isEmpty())
{
replicationServer.setReplicationServer(replServers);
replicationServer.commit();
@@ -2069,7 +2068,7 @@
logger.info(LocalizableMessage.raw("Updating references in domain " +
domain.getBaseDN()+" on " + serverDisplay + "."));
replServers.remove(replServer);
- if (replServers.size() > 0)
+ if (!replServers.isEmpty())
{
domain.setReplicationServer(replServers);
domain.commit();
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/JavaArgumentsDialog.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/JavaArgumentsDialog.java
index fdd837e..59d7291 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/JavaArgumentsDialog.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/JavaArgumentsDialog.java
@@ -578,7 +578,7 @@
cancelButton.setEnabled(true);
okButton.setEnabled(true);
- if (returnValue.size() > 0)
+ if (!returnValue.isEmpty())
{
displayError(Utils.getMessageFromCollection(returnValue, "\n"),
INFO_ERROR_TITLE.get());
diff --git a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/SecurityOptionsDialog.java b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/SecurityOptionsDialog.java
index a4811f3..1113555 100644
--- a/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/SecurityOptionsDialog.java
+++ b/opendj-server-legacy/src/main/java/org/opends/quicksetup/installer/ui/SecurityOptionsDialog.java
@@ -698,7 +698,7 @@
cancelButton.setEnabled(true);
okButton.setEnabled(true);
- if (returnValue.size() > 0)
+ if (!returnValue.isEmpty())
{
displayError(Utils.getMessageFromCollection(returnValue, "\n"),
INFO_ERROR_TITLE.get());
@@ -929,7 +929,7 @@
Installer.MIN_PORT_VALUE, Installer.MAX_PORT_VALUE));
}
}
- setValidLater(cbEnableSSL, errorMsgs.size() == 0);
+ setValidLater(cbEnableSSL, errorMsgs.isEmpty());
return errorMsgs;
}
@@ -969,7 +969,7 @@
}
}
- pathValid = errorMsgs.size() == 0;
+ pathValid = errorMsgs.isEmpty();
}
String pwd = String.valueOf(tfKeystorePwd.getPassword());
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/admin/ManagedObjectPath.java b/opendj-server-legacy/src/main/java/org/opends/server/admin/ManagedObjectPath.java
index bb35755..a20c57d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/admin/ManagedObjectPath.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/admin/ManagedObjectPath.java
@@ -837,7 +837,7 @@
if (r instanceof InstantiableRelationDefinition) {
InstantiableRelationDefinition<? super C, ? super S> ir =
(InstantiableRelationDefinition<? super C, ? super S>) r;
- if (elements.size() == 0) {
+ if (elements.isEmpty()) {
return parent().child(ir, nd, "null");
} else {
return parent().child(ir, nd,
@@ -1302,10 +1302,9 @@
* path element does not comprise of an instantiable
* relation.
*/
- @SuppressWarnings("unchecked")
public ManagedObjectPath<C, S> rename(String newName)
throws IllegalStateException {
- if (elements.size() == 0) {
+ if (elements.isEmpty()) {
throw new IllegalStateException("Cannot rename an empty path");
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java
index 17eadb9..6ea3df0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/MemoryBackend.java
@@ -177,10 +177,7 @@
}
baseDNSet = new HashSet<>();
- for (DN dn : baseDNs)
- {
- baseDNSet.add(dn);
- }
+ Collections.addAll(baseDNSet, baseDNs);
entryMap = new LinkedHashMap<>();
childDNs = new HashMap<>();
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
index d082f13..ccd26be 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/NullBackend.java
@@ -163,10 +163,7 @@
public synchronized void openBackend() throws ConfigException, InitializationException
{
baseDNSet = new HashSet<>();
- for (DN dn : baseDNs)
- {
- baseDNSet.add(dn);
- }
+ Collections.addAll(baseDNSet, baseDNs);
// Register base DNs.
for (DN dn : baseDNs)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VerifyJob.java b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VerifyJob.java
index c51ac72..8e0a903 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VerifyJob.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/backends/jeb/VerifyJob.java
@@ -432,14 +432,14 @@
{
iterateID2Subtree();
}
- else if (attrIndexList.size() > 0)
+ else if (!attrIndexList.isEmpty())
{
for (Index index : attrIndexList.get(0).getAllIndexes())
{
iterateAttrIndex(index);
}
}
- else if (vlvIndexList.size() > 0)
+ else if (!vlvIndexList.isEmpty())
{
iterateVLVIndex(vlvIndexList.get(0), true);
}
@@ -1565,7 +1565,7 @@
{
totalCount = id2s.getRecordCount();
}
- else if(attrIndexList.size() > 0)
+ else if(!attrIndexList.isEmpty())
{
AttributeIndex attrIndex = attrIndexList.get(0);
totalCount = 0;
@@ -1574,7 +1574,7 @@
totalCount += getRecordCount(index);
}
}
- else if (vlvIndexList.size() > 0)
+ else if (!vlvIndexList.isEmpty())
{
totalCount = vlvIndexList.get(0).getRecordCount();
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java
index a2d586d..ae14463 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/ConfigAttribute.java
@@ -528,8 +528,8 @@
if (!isMultiValued)
{
if (numValues > 1
- || (hasPendingValues && pendingValues.size() > 0)
- || (!hasPendingValues && activeValues.size() > 0))
+ || (hasPendingValues && !pendingValues.isEmpty())
+ || (!hasPendingValues && !activeValues.isEmpty()))
{
throw new ConfigException(ERR_CONFIG_ATTR_ADD_VALUES_IS_SINGLE_VALUED.get(name));
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
index 767b4f9..e8fcab6 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/DNConfigAttribute.java
@@ -980,7 +980,7 @@
*/
public void toJMXAttribute(AttributeList attributeList)
{
- if (activeValues.size() > 0)
+ if (!activeValues.isEmpty())
{
if (isMultiValued())
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java
index d36be29..a00055f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/IntegerConfigAttribute.java
@@ -1280,7 +1280,7 @@
*/
public void toJMXAttribute(AttributeList attributeList)
{
- if (activeValues.size() > 0)
+ if (!activeValues.isEmpty())
{
if (isMultiValued())
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java
index 755ca49..2ee6f18 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/MultiChoiceConfigAttribute.java
@@ -987,7 +987,7 @@
*/
public void toJMXAttribute(AttributeList attributeList)
{
- if (activeValues.size() > 0)
+ if (!activeValues.isEmpty())
{
if (isMultiValued())
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java b/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java
index fcf7b66..f60253e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/config/StringConfigAttribute.java
@@ -899,7 +899,7 @@
*/
public void toJMXAttribute(AttributeList attributeList)
{
- if (activeValues.size() > 0)
+ if (!activeValues.isEmpty())
{
if (isMultiValued())
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/controls/ServerSideSortRequestControl.java b/opendj-server-legacy/src/main/java/org/opends/server/controls/ServerSideSortRequestControl.java
index c7eb98c..a8914c0 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/controls/ServerSideSortRequestControl.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/controls/ServerSideSortRequestControl.java
@@ -394,7 +394,7 @@
{
buffer.append("SortOrder(");
- if (decodedKeyList.size() > 0)
+ if (!decodedKeyList.isEmpty())
{
decodedKeyToString(decodedKeyList.get(0), buffer);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
index ddb7c1e..6a03958 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/core/DirectoryServer.java
@@ -1989,25 +1989,9 @@
Map<String, List<ConfigDeleteListener>> deleteListeners,
Map<String, List<ConfigChangeListener>> changeListeners)
{
- List<ConfigAddListener> cfgAddListeners = configEntry.getAddListeners();
- if (cfgAddListeners != null && cfgAddListeners.size() > 0)
- {
- addListeners.put(configEntry.getDN().toString(), cfgAddListeners);
- }
-
- List<ConfigDeleteListener> cfgDeleteListeners =
- configEntry.getDeleteListeners();
- if (cfgDeleteListeners != null && cfgDeleteListeners.size() > 0)
- {
- deleteListeners.put(configEntry.getDN().toString(), cfgDeleteListeners);
- }
-
- List<ConfigChangeListener> cfgChangeListeners =
- configEntry.getChangeListeners();
- if (cfgChangeListeners != null && cfgChangeListeners.size() > 0)
- {
- changeListeners.put(configEntry.getDN().toString(), cfgChangeListeners);
- }
+ put(addListeners, configEntry, configEntry.getAddListeners());
+ put(deleteListeners, configEntry, configEntry.getDeleteListeners());
+ put(changeListeners, configEntry, configEntry.getChangeListeners());
for (ConfigEntry child : configEntry.getChildren().values())
{
@@ -2015,7 +1999,13 @@
}
}
-
+ private <T> void put(Map<String, List<T>> listeners, ConfigEntry configEntry, List<T> cfgListeners)
+ {
+ if (cfgListeners != null && !cfgListeners.isEmpty())
+ {
+ listeners.put(configEntry.getDN().toString(), cfgListeners);
+ }
+ }
/**
* Retrieves the set of backend initialization listeners that have been
@@ -5990,7 +5980,7 @@
{
for (HostPort listener : c.getListeners())
{
- if (usedListeners.contains(listener))
+ if (!usedListeners.add(listener))
{
// The port was already specified: this is a configuration error,
// log a message.
@@ -5998,14 +5988,10 @@
logger.error(message);
errorMessages.add(message);
}
- else
- {
- usedListeners.add(listener);
- }
}
}
- if (errorMessages.size() > 0)
+ if (!errorMessages.isEmpty())
{
throw new ConfigException(ERR_ERROR_STARTING_CONNECTION_HANDLERS.get());
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
index 74b54af..55ca6aa 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/crypto/CryptoManagerImpl.java
@@ -626,7 +626,7 @@
final SearchRequest request =
newSearchRequest(entryDN, SearchScope.BASE_OBJECT, FILTER_OC_INSTANCE_KEY).addAttribute("dn");
final InternalSearchOperation searchOp = icc.processSearch(request);
- if (0 == searchOp.getSearchEntries().size()) {
+ if (searchOp.getSearchEntries().isEmpty()) {
final Entry entry = new Entry(entryDN, null, null, null);
entry.addObjectClass(DirectoryServer.getTopObjectClass());
entry.addObjectClass(ocInstanceKey);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/DiskSpaceMonitor.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/DiskSpaceMonitor.java
index 3b48992..1ef1731 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/DiskSpaceMonitor.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/DiskSpaceMonitor.java
@@ -205,7 +205,7 @@
private boolean isEmpty()
{
- return allHandlers.size() == 0;
+ return allHandlers.isEmpty();
}
private void addHandler(MonitoredDirectory handler)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/JMXAlertHandler.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/JMXAlertHandler.java
index 370add5..ee96969 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/JMXAlertHandler.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/JMXAlertHandler.java
@@ -28,6 +28,7 @@
import org.forgerock.i18n.LocalizableMessage;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.atomic.AtomicLong;
@@ -222,16 +223,10 @@
for (JMXMBean mBean : mBeans.values())
{
MBeanInfo mBeanInfo = mBean.getMBeanInfo();
- for (MBeanNotificationInfo notification: mBeanInfo.getNotifications())
- {
- notifications.add(notification);
- }
+ Collections.addAll(notifications, mBeanInfo.getNotifications());
}
- MBeanNotificationInfo[] notificationArray =
- new MBeanNotificationInfo[notifications.size()];
- notifications.toArray(notificationArray);
- return notificationArray;
+ return notifications.toArray(new MBeanNotificationInfo[notifications.size()]);
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/ParallelWorkQueue.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/ParallelWorkQueue.java
index 67d600a..6310186 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/ParallelWorkQueue.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/ParallelWorkQueue.java
@@ -522,7 +522,7 @@
@Override
public boolean isIdle()
{
- if (opQueue.size() > 0) {
+ if (!opQueue.isEmpty()) {
return false;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java
index 71f6857..91871f4 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/PasswordPolicyStateExtendedOperation.java
@@ -674,7 +674,7 @@
writer.writeStartSequence();
writer.writeEnumerated(opType);
- if (values != null && values.size() > 0)
+ if (values != null && !values.isEmpty())
{
writer.writeStartSequence();
for (long l : values)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/RandomPasswordGenerator.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/RandomPasswordGenerator.java
index eadd499..6bda156 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/RandomPasswordGenerator.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/RandomPasswordGenerator.java
@@ -109,7 +109,7 @@
{
encodedCharacterSets = configuration.getPasswordCharacterSet();
- if (encodedCharacterSets.size() == 0)
+ if (encodedCharacterSets.isEmpty())
{
LocalizableMessage message = ERR_RANDOMPWGEN_NO_CHARSETS.get(configEntryDN);
throw new ConfigException(message);
@@ -283,7 +283,7 @@
try
{
SortedSet<String> currentPasSet = configuration.getPasswordCharacterSet();
- if (currentPasSet.size() == 0)
+ if (currentPasSet.isEmpty())
{
throw new ConfigException(ERR_RANDOMPWGEN_NO_CHARSETS.get(cfgEntryDN));
}
@@ -382,7 +382,7 @@
try
{
newEncodedCharacterSets = configuration.getPasswordCharacterSet();
- if (newEncodedCharacterSets.size() == 0)
+ if (newEncodedCharacterSets.isEmpty())
{
ccr.addMessage(ERR_RANDOMPWGEN_NO_CHARSETS.get(configEntryDN));
ccr.setResultCodeIfSuccess(ResultCode.OBJECTCLASS_VIOLATION);
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SimilarityBasedPasswordValidator.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SimilarityBasedPasswordValidator.java
index 5dbfb9a..9310c1c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/SimilarityBasedPasswordValidator.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/SimilarityBasedPasswordValidator.java
@@ -99,12 +99,12 @@
? ByteString.empty()
: newPassword;
- if (currentPasswords == null || currentPasswords.size() == 0) {
+ if (currentPasswords == null || currentPasswords.isEmpty()) {
// This validator requires access to at least one current password.
// If we don't have a current password, then we can't validate it, so
// we'll have to assume it is OK. Ideally, the password policy should be
// configured to always require the current password, but even then the
- // current password probably won't be availble during an administrative
+ // current password probably won't be available during an administrative
// password reset.
return true;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java
index 13c93d0..8060e25 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/StaticGroup.java
@@ -536,8 +536,7 @@
ERR_STATICGROUP_ADD_MEMBER_UPDATE_FAILED.get(userDN, groupEntryDN, modifyOperation.getErrorMessage()));
}
- LinkedHashSet<CompactDn> newMemberDNs = new LinkedHashSet<>(memberDNs.size()+1);
- newMemberDNs.addAll(memberDNs);
+ LinkedHashSet<CompactDn> newMemberDNs = new LinkedHashSet<CompactDn>(memberDNs);
newMemberDNs.add(compactUserDN);
memberDNs = newMemberDNs;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/extensions/TraditionalWorkQueue.java b/opendj-server-legacy/src/main/java/org/opends/server/extensions/TraditionalWorkQueue.java
index 18d6ba5..b72e299 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/extensions/TraditionalWorkQueue.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/extensions/TraditionalWorkQueue.java
@@ -772,7 +772,7 @@
queueReadLock.lock();
try
{
- if (opQueue.size() > 0)
+ if (!opQueue.isEmpty())
{
return false;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/plugins/AttributeCleanupPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/plugins/AttributeCleanupPlugin.java
index 14b85a0..466b43c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/plugins/AttributeCleanupPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/plugins/AttributeCleanupPlugin.java
@@ -312,30 +312,20 @@
isValid = false;
}
- /*
- * Check for duplicates.
- */
+ // Check for duplicates.
final String nfromAttr = toLowerCase(fromAttr);
- if (fromAttrs.contains(nfromAttr))
+ if (!fromAttrs.add(nfromAttr))
{
messages.add(ERR_PLUGIN_ATTR_CLEANUP_DUPLICATE_VALUE.get(fromAttr));
isValid = false;
}
- else
- {
- fromAttrs.add(nfromAttr);
- }
- /*
- * Check that attribute does not map to itself.
- */
+ // Check that attribute does not map to itself.
if (nfromAttr.equals(toLowerCase(toAttr)))
{
- messages
- .add(ERR_PLUGIN_ATTR_CLEANUP_EQUAL_VALUES.get(fromAttr, toAttr));
+ messages.add(ERR_PLUGIN_ATTR_CLEANUP_EQUAL_VALUES.get(fromAttr, toAttr));
isValid = false;
}
-
}
return isValid;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
index 73f246e..4a435d3 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/plugin/FractionalLDIFImportPlugin.java
@@ -468,7 +468,7 @@
private static boolean add(AttributeBuilder attrBuilder, String className,
Set<String> values)
{
- if (values.size() > 0)
+ if (!values.isEmpty())
{
attrBuilder.add(className + ":" + Utils.joinAsString(",", values));
return true;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ModifyCommonMsg.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ModifyCommonMsg.java
index 42068f4..bb00264 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ModifyCommonMsg.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ModifyCommonMsg.java
@@ -121,7 +121,7 @@
*/
protected byte[] encodeMods(List<Modification> mods)
{
- if ((mods == null) || (mods.size() == 0))
+ if (mods == null || mods.isEmpty())
{
return new byte[0];
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ReplSessionSecurity.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ReplSessionSecurity.java
index 6cdb5d8..1099ad7 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ReplSessionSecurity.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/protocol/ReplSessionSecurity.java
@@ -22,7 +22,7 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
- * Portions Copyright 2011-2014 ForgeRock AS
+ * Portions Copyright 2011-2015 ForgeRock AS
*/
package org.opends.server.replication.protocol;
@@ -117,7 +117,7 @@
final SortedSet<String> sslCipherSuites,
final boolean sslEncryption) throws ConfigException
{
- if (sslProtocols == null || sslProtocols.size() == 0)
+ if (sslProtocols == null || sslProtocols.isEmpty())
{
this.sslProtocols = null;
}
@@ -127,7 +127,7 @@
sslProtocols.toArray(this.sslProtocols);
}
- if (sslCipherSuites == null || sslCipherSuites.size() == 0)
+ if (sslCipherSuites == null || sslCipherSuites.isEmpty())
{
this.sslCipherSuites = null;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServerDomain.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServerDomain.java
index 5474067..8a6b5f5 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServerDomain.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/ReplicationServerDomain.java
@@ -650,7 +650,7 @@
// Return computed structures
PreparedAssuredInfo preparedAssuredInfo = new PreparedAssuredInfo();
- if (expectedServers.size() > 0)
+ if (!expectedServers.isEmpty())
{
// Some other acks to wait for
preparedAssuredInfo.expectedAcksInfo = new SafeReadExpectedAcksInfo(csn,
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/SafeReadExpectedAcksInfo.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/SafeReadExpectedAcksInfo.java
index 83e455f..9a57f4e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/SafeReadExpectedAcksInfo.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/SafeReadExpectedAcksInfo.java
@@ -89,7 +89,7 @@
expectedServers);
// Keep track of potential servers detected in wrong status
- if (wrongStatusServers.size() > 0)
+ if (!wrongStatusServers.isEmpty())
{
hasWrongStatus = true;
failedServers = wrongStatusServers;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/ChangeNumberIndexer.java b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/ChangeNumberIndexer.java
index 03e3484..6569a04 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/ChangeNumberIndexer.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/replication/server/changelog/file/ChangeNumberIndexer.java
@@ -504,7 +504,7 @@
nextChangeForInsertDBCursor.next();
}
catch (AbortedChangelogCursorException e) {
- if (domainsToClear.size() == 0)
+ if (domainsToClear.isEmpty())
{
// There is no domain to clear, thus it is
// not expected that a cursor is aborted
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java
index b787270..699a332 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ExportTask.java
@@ -34,6 +34,7 @@
import java.io.File;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -294,10 +295,7 @@
}
ArrayList<DN> defaultIncludeBranches = new ArrayList<>(backend.getBaseDNs().length);
- for (DN dn : backend.getBaseDNs())
- {
- defaultIncludeBranches.add(dn);
- }
+ Collections.addAll(defaultIncludeBranches, backend.getBaseDNs());
ArrayList<DN> excludeBranches = new ArrayList<>();
if (excludeBranchStrings != null)
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
index d27e887..7cf50ad 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ImportTask.java
@@ -34,6 +34,7 @@
import java.io.File;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
@@ -376,10 +377,7 @@
// Make sure the selected backend will handle all the include branches
defaultIncludeBranches = new ArrayList<>(backend.getBaseDNs().length);
- for (DN dn : backend.getBaseDNs())
- {
- defaultIncludeBranches.add(dn);
- }
+ Collections.addAll(defaultIncludeBranches, backend.getBaseDNs());
for(DN includeBranch : includeBranches)
{
@@ -557,10 +555,7 @@
// Find backends with subordinate base DNs that should be excluded from the import.
defaultIncludeBranches = new HashSet<>(backend.getBaseDNs().length);
- for (DN dn : backend.getBaseDNs())
- {
- defaultIncludeBranches.add(dn);
- }
+ Collections.addAll(defaultIncludeBranches, backend.getBaseDNs());
if (backend.getSubordinateBackends() != null)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java
index 51192b2..12e7cba 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tasks/ShutdownTask.java
@@ -97,7 +97,7 @@
AttributeType attrType =
DirectoryServer.getAttributeType(ATTR_SHUTDOWN_MESSAGE, true);
List<Attribute> attrList = taskEntry.getAttribute(attrType);
- if ((attrList != null) && (attrList.size() > 0))
+ if (attrList != null && !attrList.isEmpty())
{
Attribute attr = attrList.get(0);
if (!attr.isEmpty())
@@ -110,7 +110,7 @@
attrType = DirectoryServer.getAttributeType(ATTR_RESTART_SERVER, true);
attrList = taskEntry.getAttribute(attrType);
- if ((attrList != null) && (attrList.size() > 0))
+ if (attrList != null && !attrList.isEmpty())
{
Attribute attr = attrList.get(0);
if (!attr.isEmpty())
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
index c7505c2..26add20 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/BackUpDB.java
@@ -49,6 +49,7 @@
import org.forgerock.i18n.slf4j.LocalizedLogger;
import org.forgerock.opendj.config.server.ConfigException;
import org.forgerock.opendj.ldap.ByteString;
+import org.forgerock.util.Utils;
import org.opends.server.admin.std.server.BackendCfg;
import org.opends.server.api.Backend;
import org.opends.server.api.Backend.BackendOperation;
@@ -345,29 +346,17 @@
// Check that the backendID has not been expressed twice.
HashSet<String> backendIDLowerCase = new HashSet<>();
HashSet<String> repeatedBackendIds = new HashSet<>();
- StringBuilder repeatedBackends = new StringBuilder();
for (String id : backendID.getValues())
{
String lId = id.toLowerCase();
- if (backendIDLowerCase.contains(lId))
+ if (!backendIDLowerCase.add(lId))
{
- if (!repeatedBackendIds.contains(lId))
- {
- repeatedBackendIds.add(lId);
- if (repeatedBackends.length() > 0)
- {
- repeatedBackends.append(", ");
- }
- repeatedBackends.append(id);
- }
- }
- else
- {
- backendIDLowerCase.add(lId);
+ repeatedBackendIds.add(lId);
}
}
- if (repeatedBackends.length() > 0)
+ if (!repeatedBackendIds.isEmpty())
{
+ String repeatedBackends = Utils.joinAsString(", ", repeatedBackendIds);
LocalizableMessage message = ERR_BACKUPDB_REPEATED_BACKEND_ID.get(repeatedBackends);
err.println(wrapText(message, MAX_LINE_WIDTH));
err.println(argParser.getUsage());
@@ -442,7 +431,7 @@
addIfHasValue(attributes, ATTR_TASK_BACKUP_SIGN_HASH, signHash);
List<String> backendIDs = backendID.getValues();
- if (backendIDs != null && backendIDs.size() > 0) {
+ if (backendIDs != null && !backendIDs.isEmpty()) {
ArrayList<ByteString> values = new ArrayList<>(backendIDs.size());
for (String s : backendIDs) {
values.add(ByteString.valueOf(s));
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java
index 3d7e41e..cb5b71e 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/InstallDSArgumentParser.java
@@ -438,7 +438,7 @@
checkImportDataArguments(errorMessages);
checkSecurityArguments(errorMessages);
- if (errorMessages.size() > 0)
+ if (!errorMessages.isEmpty())
{
throw new ArgumentException(ERR_CANNOT_INITIALIZE_ARGS.get(
Utils.getMessageFromCollection(errorMessages, Constants.LINE_SEPARATOR)));
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/JavaPropertiesToolArgumentParser.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/JavaPropertiesToolArgumentParser.java
index c2efae4..a1cbc9f 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/JavaPropertiesToolArgumentParser.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/JavaPropertiesToolArgumentParser.java
@@ -142,7 +142,7 @@
ERR_JAVAPROPERTIES_WITH_DESTINATION_FILE.get(value));
}
}
- if (errorMessages.size() > 0)
+ if (!errorMessages.isEmpty())
{
LocalizableMessage message = ERR_CANNOT_INITIALIZE_ARGS.get(
Utils.getMessageFromCollection(errorMessages,
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java
index 79349ac..e0e218d 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/LDAPSearch.java
@@ -1095,7 +1095,7 @@
ArrayList<String> filterAndAttributeStrings =
argParser.getTrailingArguments();
- if(filterAndAttributeStrings.size() > 0)
+ if(!filterAndAttributeStrings.isEmpty())
{
// the list of trailing arguments should be structured as follow:
// - If a filter file is present, trailing arguments are considered
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java
index 8489327..1535074 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/ManageTasks.java
@@ -404,7 +404,7 @@
private void printSummaryTable()
throws LDAPException, IOException, DecodeException {
List<TaskEntry> entries = taskClient.getTaskEntries();
- if (entries.size() > 0) {
+ if (!entries.isEmpty()) {
TableBuilder table = new TableBuilder();
Map<String, TaskEntry> mapIdToEntry = new TreeMap<>();
for (TaskEntry entry : entries) {
@@ -452,7 +452,7 @@
List<Integer> cancelableIndices = new ArrayList<>();
List<TaskEntry> entries = taskClient.getTaskEntries();
MenuBuilder<Void> menuBuilder = new MenuBuilder<>(this);
- if (entries.size() > 0) {
+ if (!entries.isEmpty()) {
Map<String, TaskEntry> mapIdToEntry = new TreeMap<>();
for (TaskEntry entry : entries) {
String taskId = entry.getId();
@@ -489,7 +489,7 @@
INFO_TASKINFO_CMD_REFRESH.get(),
new PrintSummaryTop());
- if (cancelableIndices.size() > 0) {
+ if (!cancelableIndices.isEmpty()) {
menuBuilder.addCharOption(
INFO_TASKINFO_CMD_CANCEL_CHAR.get(),
INFO_TASKINFO_CMD_CANCEL.get(),
@@ -623,7 +623,7 @@
INFO_TASKINFO_CMD_REFRESH.get(),
new PrintTaskInfo(taskId));
List<LocalizableMessage> logs = taskEntry.getLogMessages();
- if (logs != null && logs.size() > 0) {
+ if (logs != null && !logs.isEmpty()) {
menuBuilder.addCharOption(
INFO_TASKINFO_CMD_VIEW_LOGS_CHAR.get(),
INFO_TASKINFO_CMD_VIEW_LOGS.get(),
@@ -757,7 +757,7 @@
table.startRow();
table.appendCell(attrName);
List<String> values = taskSpecificAttrs.get(attrName);
- if (values.size() > 0) {
+ if (!values.isEmpty()) {
table.appendCell(values.get(0));
}
if (values.size() > 1) {
@@ -778,8 +778,7 @@
// Print the last log message if any
List<LocalizableMessage> logs = taskEntry.getLogMessages();
- if (logs != null && logs.size() > 0) {
-
+ if (logs != null && !logs.isEmpty()) {
// Create a table for the last log entry
table = new TableBuilder();
table.appendHeading(INFO_TASKINFO_FIELD_LAST_LOG.get());
@@ -797,8 +796,7 @@
app.getOutputStream().println();
} catch (Exception e) {
- app.println(ERR_TASKINFO_RETRIEVING_TASK_ENTRY.get(
- taskId, e.getMessage()));
+ app.println(ERR_TASKINFO_RETRIEVING_TASK_ENTRY.get(taskId, e.getMessage()));
return MenuResult.again();
}
return MenuResult.success(taskEntry);
@@ -873,7 +871,7 @@
// Create a table for the last log entry
TableBuilder table = new TableBuilder();
table.appendHeading(INFO_TASKINFO_FIELD_LOG.get());
- if (logs != null && logs.size() > 0) {
+ if (logs != null && !logs.isEmpty()) {
for (LocalizableMessage log : logs) {
table.startRow();
table.appendCell(log);
@@ -923,8 +921,8 @@
public MenuResult<Void> invoke(ManageTasks app)
throws ClientException
{
- if (taskIds != null && taskIds.size() > 0) {
- if (cancelableIndices != null && cancelableIndices.size() > 0) {
+ if (taskIds != null && !taskIds.isEmpty()) {
+ if (cancelableIndices != null && !cancelableIndices.isEmpty()) {
// Prompt for the task number
Integer index = null;
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
index 4d58b72..bedeb45 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/RebuildIndex.java
@@ -189,7 +189,8 @@
return 1;
}
- if (indexList.getValues().size() <= 0 && !rebuildAll.isPresent()
+ if (indexList.getValues().isEmpty()
+ && !rebuildAll.isPresent()
&& !rebuildDegraded.isPresent())
{
final LocalizableMessage message =
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
index 0d10b27..d9639cf 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/dsreplication/ReplicationCliArgumentParser.java
@@ -357,7 +357,7 @@
}
}
}
- if (errors.size() > 0)
+ if (!errors.isEmpty())
{
for (LocalizableMessage error : errors)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
index 7257a1d..56f1abe 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/status/StatusCli.java
@@ -573,7 +573,7 @@
private void writeAdministrativeUserContents(ServerDescriptor desc, int maxLabelWidth)
{
Set<DN> administrators = desc.getAdministrativeUsers();
- if (administrators.size() > 0)
+ if (!administrators.isEmpty())
{
TreeSet<DN> ordered = new TreeSet<>(administrators);
for (DN dn : ordered)
@@ -701,7 +701,7 @@
}
Set<ConnectionHandlerDescriptor> allHandlers = desc.getConnectionHandlers();
- if (allHandlers.size() == 0)
+ if (allHandlers.isEmpty())
{
if (desc.getStatus() == ServerDescriptor.ServerStatus.STARTED)
{
@@ -752,7 +752,7 @@
replicas.addAll(backend.getBaseDns());
}
}
- if (replicas.size() == 0)
+ if (replicas.isEmpty())
{
if (desc.getStatus() == ServerDescriptor.ServerStatus.STARTED)
{
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskClient.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskClient.java
index fc8e991..dd7a7dd 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskClient.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskClient.java
@@ -228,7 +228,7 @@
// add dependency IDs
List<String> dependencyIds = information.getDependencyIds();
- if (dependencyIds != null && dependencyIds.size() > 0) {
+ if (dependencyIds != null && !dependencyIds.isEmpty()) {
ArrayList<ByteString> dependencyIdValues = new ArrayList<>(dependencyIds.size());
for (String dependencyId : dependencyIds) {
dependencyIdValues.add(ByteString.valueOf(dependencyId));
@@ -248,7 +248,7 @@
// add completion notification email addresses
List<String> compNotifEmailAddresss =
information.getNotifyUponCompletionEmailAddresses();
- if (compNotifEmailAddresss != null && compNotifEmailAddresss.size() > 0) {
+ if (compNotifEmailAddresss != null && !compNotifEmailAddresss.isEmpty()) {
ArrayList<ByteString> compNotifEmailAddrValues = new ArrayList<>(compNotifEmailAddresss.size());
for (String emailAddr : compNotifEmailAddresss) {
compNotifEmailAddrValues.add(ByteString.valueOf(emailAddr));
@@ -259,7 +259,7 @@
// add error notification email addresses
List<String> errNotifEmailAddresss =
information.getNotifyUponErrorEmailAddresses();
- if (errNotifEmailAddresss != null && errNotifEmailAddresss.size() > 0) {
+ if (errNotifEmailAddresss != null && !errNotifEmailAddresss.isEmpty()) {
ArrayList<ByteString> errNotifEmailAddrValues = new ArrayList<>(errNotifEmailAddresss.size());
for (String emailAddr : errNotifEmailAddresss) {
errNotifEmailAddrValues.add(ByteString.valueOf(emailAddr));
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java
index e46f5db..f957b43 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/tools/tasks/TaskTool.java
@@ -309,8 +309,7 @@
taskEntry = tc.getTaskEntry(taskId);
List<LocalizableMessage> logs = taskEntry.getLogMessages();
for (LocalizableMessage log : logs) {
- if (!printedLogMessages.contains(log)) {
- printedLogMessages.add(log);
+ if (printedLogMessages.add(log)) {
out.println(log);
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java b/opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java
index 1adfa25..cb3879c 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/StaticUtils.java
@@ -2410,12 +2410,9 @@
ArrayList<String> commandAndArgs = new ArrayList<>();
commandAndArgs.add(command);
- if ((args != null) && (args.length > 0))
+ if (args != null && args.length > 0)
{
- for (String arg : args)
- {
- commandAndArgs.add(arg);
- }
+ Collections.addAll(commandAndArgs, args);
}
ProcessBuilder processBuilder = new ProcessBuilder(commandAndArgs);
@@ -3378,10 +3375,7 @@
}
ArrayList<String> stringList = new ArrayList<>(stringArray.length);
- for (String s : stringArray)
- {
- stringList.add(s);
- }
+ Collections.addAll(stringList, stringArray);
return stringList;
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/util/VersionCompatibilityIssue.java b/opendj-server-legacy/src/main/java/org/opends/server/util/VersionCompatibilityIssue.java
index 5c7cf02..ecf49ee 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/util/VersionCompatibilityIssue.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/util/VersionCompatibilityIssue.java
@@ -416,9 +416,7 @@
this.upgradeMsg = upgradeMessage;
this.reversionMsg = reversionMessage;
if (effects != null) {
- for (Effect c : effects) {
- this.effects.add(c);
- }
+ Collections.addAll(this.effects, effects);
}
}
diff --git a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
index eafc4e2..638b097 100644
--- a/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
+++ b/opendj-server-legacy/src/main/java/org/opends/server/workflowelement/localbackend/LocalBackendModifyOperation.java
@@ -1690,26 +1690,7 @@
HashSet<ByteString> clearPasswords = new HashSet<>(pwPolicyState.getClearPasswords());
if (currentPasswords != null)
{
- if (clearPasswords.isEmpty())
- {
- clearPasswords.addAll(currentPasswords);
- }
- else
- {
- // NOTE: We can't rely on the fact that Set doesn't allow
- // duplicates because technically it's possible that the values
- // aren't duplicates if they are ASN.1 elements with different types
- // (like 0x04 for a standard universal octet string type versus 0x80
- // for a simple password in a bind operation). So we have to
- // manually check for duplicates.
- for (ByteString pw : currentPasswords)
- {
- if (!clearPasswords.contains(pw))
- {
- clearPasswords.add(pw);
- }
- }
- }
+ clearPasswords.addAll(currentPasswords);
}
for (ByteString v : newPasswords)
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/admin/TestTopCfgDefnTest.java b/opendj-server-legacy/src/test/java/org/opends/server/admin/TestTopCfgDefnTest.java
index e5966d5..94afa5b 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/admin/TestTopCfgDefnTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/admin/TestTopCfgDefnTest.java
@@ -22,12 +22,10 @@
*
*
* Copyright 2008 Sun Microsystems, Inc.
+ * Portions Copyright 2015 ForgeRock AS.
*/
-
package org.opends.server.admin;
-
-
import static org.testng.Assert.*;
import org.opends.server.DirectoryServerTestCase;
@@ -35,11 +33,7 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-
-
-/**
- * TopCfgDefn test cases.
- */
+/** TopCfgDefn test cases. */
@Test(sequential = true)
public class TestTopCfgDefnTest extends DirectoryServerTestCase {
@@ -56,134 +50,81 @@
TestCaseUtils.startServer();
}
-
-
- /**
- * Tests getInstance() does not return null.
- */
+ /** Tests getInstance() does not return null. */
@Test
public void testGetInstance() {
assertNotNull(TopCfgDefn.getInstance());
}
-
-
- /**
- * Tests getName() returns "top".
- */
+ /** Tests getName() returns "top". */
@Test
public void testGetName() {
assertEquals(TopCfgDefn.getInstance().getName(), "top");
}
-
-
- /**
- * Tests that there are no property definitions.
- */
+ /** Tests that there are no property definitions. */
@Test
public void testGetAllPropertyDefinitions() {
assertTrue(TopCfgDefn.getInstance().getAllPropertyDefinitions().isEmpty());
}
-
-
- /**
- * Tests that there are no relation definitions.
- */
+ /** Tests that there are no relation definitions. */
@Test
public void testGetAllRelationDefinitions() {
assertTrue(TopCfgDefn.getInstance().getAllRelationDefinitions().isEmpty());
}
-
-
- /**
- * Tests that there are no constraints.
- */
+ /** Tests that there are no constraints. */
@Test
public void testGetAllConstraints() {
assertTrue(TopCfgDefn.getInstance().getAllConstraints().isEmpty());
}
-
-
- /**
- * Tests that there are no tags.
- */
+ /** Tests that there are no tags. */
@Test
public void testGetAllTags() {
assertTrue(TopCfgDefn.getInstance().getAllTags().isEmpty());
}
-
-
- /**
- * Tests that there is no parent.
- */
+ /** Tests that there is no parent. */
@Test
public void testGetParent() {
assertNull(TopCfgDefn.getInstance().getParent());
}
-
-
- /**
- * Tests that isTop returns true.
- */
+ /** Tests that isTop returns true. */
@Test
public void testIsTop() {
assertTrue(TopCfgDefn.getInstance().isTop());
}
-
-
- /**
- * Tests that getSynopsis throws an exception.
- */
+ /** Tests that getSynopsis throws an exception. */
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testGetSynopsis() {
assertNotNull(TopCfgDefn.getInstance().getSynopsis());
}
-
-
- /**
- * Tests that getDescription throws an exception.
- */
+ /** Tests that getDescription throws an exception. */
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testGetDescription() {
assertNotNull(TopCfgDefn.getInstance().getDescription());
}
-
-
- /**
- * Tests that getUserFriendlyName throws an exception.
- */
+ /** Tests that getUserFriendlyName throws an exception. */
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testGetUserFriendlyName() {
assertNotNull(TopCfgDefn.getInstance().getUserFriendlyName());
}
-
-
- /**
- * Tests that getUserFriendlyPluralName throws an exception.
- */
+ /** Tests that getUserFriendlyPluralName throws an exception. */
@Test(expectedExceptions = UnsupportedOperationException.class)
public void testGetUserFriendlyPluralName() {
assertNotNull(TopCfgDefn.getInstance().getUserFriendlyPluralName());
}
-
-
- /**
- * Tests that there are children.
- */
+ /** Tests that there are children. */
@Test
public void testGetAllChildren() {
- assertTrue(TopCfgDefn.getInstance().getAllChildren().size() > 0);
+ assertFalse(TopCfgDefn.getInstance().getAllChildren().isEmpty());
}
-
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java b/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java
index 2072e17..71f815c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/admin/client/ldap/AggregationClientTest.java
@@ -26,8 +26,6 @@
*/
package org.opends.server.admin.client.ldap;
-
-
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
@@ -36,16 +34,11 @@
import org.opends.server.TestCaseUtils;
import org.opends.server.admin.AdminTestCase;
-import org.opends.server.admin.DefinitionDecodingException;
import org.opends.server.admin.PropertyException;
-import org.opends.server.admin.ManagedObjectNotFoundException;
import org.opends.server.admin.TestCfg;
import org.opends.server.admin.TestChildCfgClient;
import org.opends.server.admin.TestChildCfgDefn;
import org.opends.server.admin.TestParentCfgClient;
-import org.opends.server.admin.client.AuthorizationException;
-import org.opends.server.admin.client.CommunicationException;
-import org.opends.server.admin.client.ConcurrentModificationException;
import org.opends.server.admin.client.ManagedObject;
import org.opends.server.admin.client.ManagedObjectDecodingException;
import org.opends.server.admin.client.ManagementContext;
@@ -56,8 +49,6 @@
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;
-
-
/**
* Test cases for aggregations on the client-side.
*/
@@ -365,13 +356,8 @@
/** Retrieve the named test parent managed object. */
- private TestParentCfgClient getTestParent(ManagementContext context,
- String name) throws DefinitionDecodingException,
- ManagedObjectDecodingException, AuthorizationException,
- ManagedObjectNotFoundException, ConcurrentModificationException,
- CommunicationException {
- ManagedObject<RootCfgClient> root = context
- .getRootConfigurationManagedObject();
+ private TestParentCfgClient getTestParent(ManagementContext context, String name) throws Exception {
+ ManagedObject<RootCfgClient> root = context.getRootConfigurationManagedObject();
return root.getChild(TestCfg.getTestOneToManyParentRelationDefinition(),
name).getConfiguration();
}
@@ -383,11 +369,8 @@
SortedSet<String> values = new TreeSet<>(TestChildCfgDefn
.getInstance().getAggregationPropertyPropertyDefinition());
if (expected != null) {
- for (String value : expected) {
- values.add(value);
- }
+ Collections.addAll(values, expected);
}
Assert.assertEquals((Object) actual, (Object) values);
}
-
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/admin/server/AggregationServerTest.java b/opendj-server-legacy/src/test/java/org/opends/server/admin/server/AggregationServerTest.java
index 880cb99..2cbfc7d 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/admin/server/AggregationServerTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/admin/server/AggregationServerTest.java
@@ -27,6 +27,7 @@
package org.opends.server.admin.server;
import java.util.Collection;
+import java.util.Collections;
import java.util.List;
import java.util.SortedSet;
import java.util.TreeSet;
@@ -912,9 +913,7 @@
SortedSet<String> values = new TreeSet<>(TestChildCfgDefn
.getInstance().getAggregationPropertyPropertyDefinition());
if (expected != null) {
- for (String value : expected) {
- values.add(value);
- }
+ Collections.addAll(values, expected);
}
Assert.assertEquals((Object) actual, (Object) values);
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/api/plugin/DirectoryServerPluginTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/api/plugin/DirectoryServerPluginTestCase.java
index ad00480..52202ca 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/api/plugin/DirectoryServerPluginTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/api/plugin/DirectoryServerPluginTestCase.java
@@ -26,10 +26,9 @@
*/
package org.opends.server.api.plugin;
-
-
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.HashSet;
import java.util.Iterator;
@@ -51,12 +50,8 @@
import static org.testng.Assert.*;
-
-
-/**
- * A set of generic test cases for the Directory Server plugin API.
- */
- public class DirectoryServerPluginTestCase
+/** A set of generic test cases for the Directory Server plugin API. */
+public class DirectoryServerPluginTestCase
extends PluginAPITestCase
{
@BeforeClass
@@ -814,18 +809,13 @@
"ds-cfg-plugin-type: intermediateResponse");
PluginCfg configuration =
- AdminTestCaseUtils.getConfiguration(PluginCfgDefn.getInstance(),
- pluginEntry);
-
+ AdminTestCaseUtils.getConfiguration(PluginCfgDefn.getInstance(), pluginEntry);
NullPlugin nullPlugin = new NullPlugin();
DN pluginEntryDN = DN.valueOf("cn=Null Plugin,cn=Plugins,cn=config");
HashSet<PluginType> pluginTypes = new HashSet<>();
- for (PluginType t : PluginType.values())
- {
- pluginTypes.add(t);
- }
+ Collections.addAll(pluginTypes, PluginType.values());
nullPlugin.initializeInternal(configuration.dn(), pluginTypes,
configuration.isInvokeForInternalOperations());
@@ -902,17 +892,12 @@
"ds-cfg-plugin-type: intermediateResponse");
PluginCfg configuration =
- AdminTestCaseUtils.getConfiguration(PluginCfgDefn.getInstance(),
- pluginEntry);
-
+ AdminTestCaseUtils.getConfiguration(PluginCfgDefn.getInstance(), pluginEntry);
NullPlugin nullPlugin = new NullPlugin();
HashSet<PluginType> pluginTypes = new HashSet<>();
- for (PluginType t : PluginType.values())
- {
- pluginTypes.add(t);
- }
+ Collections.addAll(pluginTypes, PluginType.values());
nullPlugin.initializeInternal(configuration.dn(), pluginTypes,
configuration.isInvokeForInternalOperations());
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java
index 2626c3b..de43924 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTestCase.java
@@ -228,11 +228,7 @@
argList.add("-s");
argList.add("sub");
argList.add(filter);
- String[] attrs=attr.split("\\s+");
- for(String a : attrs)
- {
- argList.add(a);
- }
+ Collections.addAll(argList, attr.split("\\s+"));
String[] args = new String[argList.size()];
oStream.reset();
int retVal =
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTests.java b/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTests.java
index 13aa564..822938f 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTests.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/authorization/dseecompat/AciTests.java
@@ -1687,10 +1687,7 @@
_searchFilter));
}
- for (String attribute : _attributes)
- {
- args.add(attribute);
- }
+ Collections.addAll(args, _attributes);
return args.toArray(new String[args.size()]);
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/crypto/CryptoManagerTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/crypto/CryptoManagerTestCase.java
index 7a7e35a..9dbfb52 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/crypto/CryptoManagerTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/crypto/CryptoManagerTestCase.java
@@ -369,7 +369,7 @@
.append(")").toString();
final SearchRequest request = newSearchRequest(baseDN, SearchScope.SINGLE_LEVEL, searchFilter).addAttribute("dn");
InternalSearchOperation searchOp = getRootConnection().processSearch(request);
- assertTrue(0 < searchOp.getSearchEntries().size());
+ assertFalse(searchOp.getSearchEntries().isEmpty());
String compromisedTime = TimeThread.getGeneralizedTime();
for (Entry e : searchOp.getSearchEntries()) {
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/crypto/GetSymmetricKeyExtendedOperationTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/crypto/GetSymmetricKeyExtendedOperationTestCase.java
index 2241795..75929f4 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/crypto/GetSymmetricKeyExtendedOperationTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/crypto/GetSymmetricKeyExtendedOperationTestCase.java
@@ -111,7 +111,7 @@
final SearchRequest request = newSearchRequest(baseDN, SearchScope.SINGLE_LEVEL, searchFilter)
.addAttribute(ConfigConstants.ATTR_CRYPTO_SYMMETRIC_KEY);
InternalSearchOperation searchOp = getRootConnection().processSearch(request);
- assertTrue(0 < searchOp.getSearchEntries().size());
+ assertFalse(searchOp.getSearchEntries().isEmpty());
final InternalClientConnection internalConnection =
InternalClientConnection.getRootConnection();
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/extensions/TLSByteChannelTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/extensions/TLSByteChannelTestCase.java
index 63af066..9588475 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/extensions/TLSByteChannelTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/extensions/TLSByteChannelTestCase.java
@@ -31,6 +31,7 @@
import java.net.URL;
import java.net.URLConnection;
import java.util.ArrayList;
+import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.ListIterator;
@@ -487,10 +488,7 @@
Set<String> set = new HashSet<>();
for (String[] array : data)
{
- for (String s : array)
- {
- set.add(s);
- }
+ Collections.addAll(set, array);
}
return set;
}
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPFilter.java b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPFilter.java
index 601afb4..a9cf1f2 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPFilter.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/protocols/ldap/TestLDAPFilter.java
@@ -225,23 +225,30 @@
{
assertEquals(decoded.getNOTComponent().toString(), filter.getNOTComponent().toString());
}
- if(decoded.getSubAnyElements() != null && decoded.getSubAnyElements().size() > 0 ||
- filter.getSubAnyElements() != null && filter.getSubAnyElements().size() > 0)
+ if(isNotEmpty(decoded.getSubAnyElements()) || isNotEmpty(filter.getSubAnyElements()))
{
assertEquals(decoded.getSubAnyElements(), filter.getSubAnyElements());
}
- if(decoded.getSubFinalElement() != null && !decoded.getSubFinalElement().toString().equals("") ||
- filter.getSubFinalElement() != null && !filter.getSubFinalElement().toString().equals(""))
+ if(isNotEmpty(decoded.getSubFinalElement()) || isNotEmpty(filter.getSubFinalElement()))
{
assertEquals(decoded.getSubFinalElement(), filter.getSubFinalElement());
}
- if(decoded.getSubInitialElement() != null && !decoded.getSubInitialElement().toString().equals("") ||
- filter.getSubInitialElement() != null && !filter.getSubInitialElement().toString().equals(""))
+ if(isNotEmpty(decoded.getSubInitialElement()) || isNotEmpty(filter.getSubInitialElement()))
{
assertEquals(decoded.getSubInitialElement(), filter.getSubInitialElement());
}
}
+ private boolean isNotEmpty(ByteString bs)
+ {
+ return bs != null && !bs.toString().equals("");
+ }
+
+ private boolean isNotEmpty(ArrayList<ByteString> col)
+ {
+ return col != null && !col.isEmpty();
+ }
+
@Test(dataProvider = "badfilterstrings", expectedExceptions = LDAPException.class)
public void testDecodeException (String filterStr, LDAPFilter filter) throws Exception
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/replication/server/AssuredReplicationServerTest.java b/opendj-server-legacy/src/test/java/org/opends/server/replication/server/AssuredReplicationServerTest.java
index 97d1f53..28829c2 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/replication/server/AssuredReplicationServerTest.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/replication/server/AssuredReplicationServerTest.java
@@ -1383,7 +1383,7 @@
{
List<List<Object>> newObjectArrayList = new ArrayList<>();
- if (objectArrayList.size() == 0)
+ if (objectArrayList.isEmpty())
{
// First time we add some parameters, create first object arrays
// Add each possible parameter as initial parameter lists
@@ -1669,7 +1669,7 @@
}
else
{ // Not enough eligible servers
- if (eligibleServers.size() > 0) // Some eligible servers anyway
+ if (!eligibleServers.isEmpty()) // Some eligible servers anyway
{
if (expectedServers.size() == eligibleServers.size()) // All eligible servers should respond in time
{
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/tools/UpgradeTestCase.java b/opendj-server-legacy/src/test/java/org/opends/server/tools/UpgradeTestCase.java
index c55fabf..ac9eb3c 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/tools/UpgradeTestCase.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/tools/UpgradeTestCase.java
@@ -28,6 +28,7 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.PrintStream;
+import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
@@ -72,14 +73,9 @@
argsList.add(configFilePath);
if (args != null)
{
- for (final String argument : args)
- {
- argsList.add(argument);
- }
+ Collections.addAll(argsList, args);
}
- final String[] mainArgs = new String[argsList.size()];
- argsList.toArray(mainArgs);
- return mainArgs;
+ return argsList.toArray(new String[argsList.size()]);
}
/**
diff --git a/opendj-server-legacy/src/test/java/org/opends/server/util/TestStaticUtils.java b/opendj-server-legacy/src/test/java/org/opends/server/util/TestStaticUtils.java
index 75dcf79..efe78bf 100644
--- a/opendj-server-legacy/src/test/java/org/opends/server/util/TestStaticUtils.java
+++ b/opendj-server-legacy/src/test/java/org/opends/server/util/TestStaticUtils.java
@@ -710,9 +710,7 @@
public void testListToArray(String[] strings) throws Exception {
if (strings != null) {
List<String> list = new ArrayList<>(strings.length);
- for (String string : strings) {
- list.add(string);
- }
+ Collections.addAll(list, strings);
Assert.assertEquals(StaticUtils.listToArray(list), strings);
} else {
Assert.assertNull(StaticUtils.listToArray(null));
--
Gitblit v1.10.0