diff options
author | Carsten Hammer | 2019-11-20 19:06:54 +0000 |
---|---|---|
committer | Alexander Kurtakov | 2019-12-11 17:13:01 +0000 |
commit | bf84edb7500f0ac62aeec92d7158137ccc4ed725 (patch) | |
tree | 046d2a4db7246a1231f7af562b47a99ecdcd5c36 | |
parent | 64699225ab687e88a61212c7f17f0eb56c9cad21 (diff) | |
download | rt.equinox.p2-bf84edb7500f0ac62aeec92d7158137ccc4ed725.tar.gz rt.equinox.p2-bf84edb7500f0ac62aeec92d7158137ccc4ed725.tar.xz rt.equinox.p2-bf84edb7500f0ac62aeec92d7158137ccc4ed725.zip |
Use jdk 5 for-each loopI20191211-1805
Replace simple uses of Iterator with a corresponding for-loop. Also add
missing braces on loops as necessary.
Change-Id: I0b989291c6067ee9d1a966ac6bd9ac280cf8fad0
Signed-off-by: Carsten Hammer <carsten.hammer@t-online.de>
21 files changed, 105 insertions, 120 deletions
diff --git a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/UniversalUniqueIdentifier.java b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/UniversalUniqueIdentifier.java index 90fa151e9..ab172c03a 100644 --- a/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/UniversalUniqueIdentifier.java +++ b/bundles/org.eclipse.equinox.p2.artifact.repository/src/org/eclipse/equinox/internal/p2/artifact/repository/simple/UniversalUniqueIdentifier.java @@ -296,8 +296,8 @@ public class UniversalUniqueIdentifier implements java.io.Serializable { @Override public String toString() { StringBuilder buffer = new StringBuilder(); - for (int i = 0; i < fBits.length; i++) - appendByteString(buffer, fBits[i]); + for (byte bit : fBits) + appendByteString(buffer, bit); return buffer.toString(); } diff --git a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java index 8de45dcbb..758520321 100644 --- a/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java +++ b/bundles/org.eclipse.equinox.p2.director/src/org/eclipse/equinox/internal/p2/director/Slicer.java @@ -172,8 +172,8 @@ public class Slicer { if (iu instanceof InstallableUnitPatch) { IInstallableUnitPatch patchIU = (IInstallableUnitPatch) iu; List<IRequirementChange> changes = patchIU.getRequirementsChange(); - for (int i = 0; i < changes.size(); i++) - aggregatedRequirements.add(changes.get(i).newValue()); + for (IRequirementChange change : changes) + aggregatedRequirements.add(change.newValue()); } if (considerMetaRequirements) @@ -186,8 +186,7 @@ public class Slicer { return; IQueryResult<IInstallableUnit> matches = possibilites.query(QueryUtil.createMatchQuery(req.getMatches()), null); int validMatches = 0; - for (Iterator<IInstallableUnit> iterator = matches.iterator(); iterator.hasNext();) { - IInstallableUnit match = iterator.next(); + for (IInstallableUnit match : matches) { if (!isApplicable(match)) continue; validMatches++; diff --git a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java index c9527e20a..19070cd35 100644 --- a/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java +++ b/bundles/org.eclipse.equinox.p2.engine/src/org/eclipse/equinox/internal/p2/engine/SimpleProfileRegistry.java @@ -454,8 +454,8 @@ public class SimpleProfileRegistry implements IProfileRegistry, IAgentService { return; List<String> subProfileIds = profile.getSubProfileIds(); - for (int i = 0; i < subProfileIds.size(); i++) { - removeProfile(subProfileIds.get(i)); + for (String subProfileId : subProfileIds) { + removeProfile(subProfileId); } internalLockProfile(profile); // The above call recursively locked the parent(s). So save it away to rewind the locking process. diff --git a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java index 1b75a563c..74f4f8382 100644 --- a/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java +++ b/bundles/org.eclipse.equinox.p2.jarprocessor/src/org/eclipse/equinox/internal/p2/jarprocessor/Utils.java @@ -307,8 +307,8 @@ public class Utils { PrintStream printStream = new PrintStream(stream); printStream.print("#Processed using Jarprocessor\n"); //$NON-NLS-1$ SortedMap<Object, Object> sorted = new TreeMap<>(props); - for (Iterator<Object> iter = sorted.keySet().iterator(); iter.hasNext();) { - String key = (String) iter.next(); + for (Object object : sorted.keySet()) { + String key = (String) object; printStream.print(key); printStream.print(" = "); //$NON-NLS-1$ printStream.print(sorted.get(key)); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointInstruction.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointInstruction.java index f3922da2d..7b379f889 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointInstruction.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TouchpointInstruction.java @@ -91,18 +91,18 @@ public class TouchpointInstruction implements ITouchpointInstruction { */ private static void appendEncoded(StringBuffer buf, String value) { char[] chars = value.toCharArray(); - for (int i = 0; i < chars.length; i++) { - switch (chars[i]) { + for (char c : chars) { + switch (c) { case '$' : case ',' : case ':' : case ';' : case '{' : case '}' : - buf.append("${#").append(Integer.toString(chars[i])).append('}'); //$NON-NLS-1$ + buf.append("${#").append(Integer.toString(c)).append('}'); //$NON-NLS-1$ break; default : - buf.append(chars[i]); + buf.append(c); } } } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java index 32b2ee46d..dd665564b 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/TranslationSupport.java @@ -297,8 +297,8 @@ public class TranslationSupport { String translation = null; for (Iterator<IInstallableUnit> iter = collected.iterator(); iter.hasNext() && translation == null;) { IInstallableUnit localizationIU = iter.next(); - for (Iterator<String> jter = locales.iterator(); jter.hasNext();) { - String localeKey = makeLocalizedKey(actualKey, jter.next()); + for (String unitlocale : locales) { + String localeKey = makeLocalizedKey(actualKey, unitlocale); translation = localizationIU.getProperty(localeKey); if (translation != null) return cacheResult(iu, localizedKey, translation); diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.java index 1c1079e1c..dd6ff6191 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/VersionFormatParser.java @@ -446,8 +446,8 @@ class VersionFormatParser { boolean isMatch(String version, int pos) { char c = version.charAt(pos); if (delimChars != null) { - for (int idx = 0; idx < delimChars.length; ++idx) - if (c == delimChars[idx]) + for (char delimChar : delimChars) + if (c == delimChar) return !inverted; return inverted; } else if (VersionParser.isLetterOrDigit(c)) @@ -672,8 +672,8 @@ class VersionFormatParser { super.setDefaults(segments); } else { // Assign defaults for all fragments - for (int idx = 0; idx < fragments.length; ++idx) - fragments[idx].setDefaults(segments); + for (Fragment fragment : fragments) + fragment.setDefaults(segments); } } @@ -681,19 +681,19 @@ class VersionFormatParser { void toString(StringBuffer sb) { if (array) { sb.append('<'); - for (int idx = 0; idx < fragments.length; ++idx) - fragments[idx].toString(sb); + for (Fragment fragment : fragments) + fragment.toString(sb); sb.append('>'); } else { if (getQualifier() == VersionFormatParser.ZERO_OR_ONE_QUALIFIER) { sb.append('['); - for (int idx = 0; idx < fragments.length; ++idx) - fragments[idx].toString(sb); + for (Fragment fragment : fragments) + fragment.toString(sb); sb.append(']'); } else { sb.append('('); - for (int idx = 0; idx < fragments.length; ++idx) - fragments[idx].toString(sb); + for (Fragment fragment : fragments) + fragment.toString(sb); sb.append(')'); } } diff --git a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/SetFunction.java b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/SetFunction.java index b23415cfb..a09a5e450 100644 --- a/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/SetFunction.java +++ b/bundles/org.eclipse.equinox.p2.metadata/src/org/eclipse/equinox/internal/p2/metadata/expression/SetFunction.java @@ -25,8 +25,8 @@ public final class SetFunction extends Function { @Override public Object evaluate(IEvaluationContext context) { HashSet<Object> result = new HashSet<>(); - for (int idx = 0; idx < operands.length; ++idx) - result.add(operands[idx].evaluate(context)); + for (Expression operand : operands) + result.add(operand.evaluate(context)); return result; } diff --git a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java index f562ff3b3..afaa5745f 100644 --- a/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java +++ b/bundles/org.eclipse.equinox.p2.operations/src/org/eclipse/equinox/p2/operations/UpdateOperation.java @@ -28,10 +28,10 @@ import org.eclipse.equinox.p2.query.*; /** * An UpdateOperation describes an operation that updates {@link IInstallableUnit}s in * a profile. - * + * * The following snippet shows how one might use an UpdateOperation to check for updates * to the profile and then install them in the background. - * + * * <pre> * UpdateOperation op = new UpdateOperation(session); * IStatus result = op.resolveModal(monitor); @@ -39,13 +39,13 @@ import org.eclipse.equinox.p2.query.*; * op.getProvisioningJob(monitor).schedule(); * } * </pre> - * + * * The life cycle of an UpdateOperation is different than that of the other * operations. Since assembling the list of possible updates may be costly, * clients should not have to create a new update operation if the desired updates * to be applied need to change. In this case, the client can set a new set of * chosen updates on the update operation and resolve again. - * + * * <pre> * UpdateOperation op = new UpdateOperation(session); * IStatus result = op.resolveModal(monitor); @@ -57,7 +57,7 @@ import org.eclipse.equinox.p2.query.*; * IStatus result = op.resolveModal(monitor); * } * </pre> - * + * * @noextend This class is not intended to be subclassed by clients. * @since 2.0 */ @@ -77,7 +77,7 @@ public class UpdateOperation extends ProfileChangeOperation { * Create an update operation on the specified provisioning session that updates * the specified IInstallableUnits. Unless otherwise specified, the operation will * be associated with the currently running profile. - * + * * @param session the session to use for obtaining provisioning services * @param toBeUpdated the IInstallableUnits to be updated. */ @@ -89,7 +89,7 @@ public class UpdateOperation extends ProfileChangeOperation { /** * Create an update operation that will update all of the user-visible installable * units in the profile (the profile roots). - * + * * @param session the session providing the provisioning services */ public UpdateOperation(ProvisioningSession session) { @@ -100,9 +100,9 @@ public class UpdateOperation extends ProfileChangeOperation { * Set the updates that should be selected from the set of available updates. * If the selected updates are not specified, then the latest available update * for each IInstallableUnit with updates will be chosen. - * + * * @param defaultUpdates the updates that should be chosen from all of the available - * updates. + * updates. */ public void setSelectedUpdates(Update[] defaultUpdates) { this.defaultUpdates = new ArrayList<>(Arrays.asList(defaultUpdates)); @@ -112,7 +112,7 @@ public class UpdateOperation extends ProfileChangeOperation { * Get the updates that have been selected from the set of available updates. * If none have been specified by the client, then the latest available update * for each IInstallableUnit with updates will be chosen. - * + * * @return the updates that should be chosen from all of the available updates */ public Update[] getSelectedUpdates() { @@ -124,7 +124,7 @@ public class UpdateOperation extends ProfileChangeOperation { /** * Get the list of all possible updates. This list may include multiple versions * of updates for the same IInstallableUnit, as well as patches to the IInstallableUnit. - * + * * @return an array of all possible updates */ public Update[] getPossibleUpdates() { @@ -143,12 +143,13 @@ public class UpdateOperation extends ProfileChangeOperation { // We must consult the planner IQueryResult<IInstallableUnit> replacements = session.getPlanner().updatesFor(iu, context, monitor); updates = new ArrayList<>(); - for (Iterator<IInstallableUnit> replacementIterator = replacements.iterator(); replacementIterator.hasNext();) { + for (IInstallableUnit replacementIU : replacements) { // see https://bugs.eclipse.org/bugs/show_bug.cgi?id=273967 - // In the case of patches, it's possible that a patch is returned as an available update - // even though it is already installed, because we are querying each IU for updates individually. + // In the case of patches, it's possible that a patch is returned as an + // available update + // even though it is already installed, because we are querying each IU for + // updates individually. // For now, we ignore any proposed update that is already installed. - IInstallableUnit replacementIU = replacementIterator.next(); IQueryResult<IInstallableUnit> alreadyInstalled = profile.query(QueryUtil.createIUQuery(replacementIU), null); if (alreadyInstalled.isEmpty()) { Update update = new Update(iu, replacementIU); @@ -275,12 +276,12 @@ public class UpdateOperation extends ProfileChangeOperation { /* * Get the IInstallable units for the specified profile - * + * * @param profileId the profile in question * @param all <code>true</code> if all IInstallableUnits in the profile should * be returned, <code>false</code> only those IInstallableUnits marked as (user visible) roots * should be returned. - * + * * @return an array of IInstallableUnits installed in the profile. */ private Collection<IInstallableUnit> getInstalledIUs() { @@ -321,7 +322,7 @@ public class UpdateOperation extends ProfileChangeOperation { * Overridden because our resolution job life cycle is different. We have a job * before we've computed the profile change request, so we must ensure that we * have already computed the profile change request. - * + * */ @Override public boolean hasResolved() { diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Utility.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Utility.java index cb950faf2..c55e67821 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Utility.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/comparator/java/Utility.java @@ -116,9 +116,9 @@ public class Utility { public static ClassFileAttribute getAttribute(MethodInfo methodInfo, char[] attributeName) { ClassFileAttribute[] attributes = methodInfo.getAttributes(); - for (int i = 0, max = attributes.length; i < max; i++) { - if (Arrays.equals(attributes[i].getAttributeName(), attributeName)) { - return attributes[i]; + for (ClassFileAttribute attribute : attributes) { + if (Arrays.equals(attribute.getAttributeName(), attributeName)) { + return attribute; } } return null; @@ -126,9 +126,9 @@ public class Utility { public static ClassFileAttribute getAttribute(FieldInfo fieldInfo, char[] attributeName) { ClassFileAttribute[] attributes = fieldInfo.getAttributes(); - for (int i = 0, max = attributes.length; i < max; i++) { - if (Arrays.equals(attributes[i].getAttributeName(), attributeName)) { - return attributes[i]; + for (ClassFileAttribute attribute : attributes) { + if (Arrays.equals(attribute.getAttributeName(), attributeName)) { + return attribute; } } return null; @@ -136,9 +136,9 @@ public class Utility { public static ClassFileAttribute getAttribute(ClassFileReader classFileReader, char[] attributeName) { ClassFileAttribute[] attributes = classFileReader.getAttributes(); - for (int i = 0, max = attributes.length; i < max; i++) { - if (Arrays.equals(attributes[i].getAttributeName(), attributeName)) { - return attributes[i]; + for (ClassFileAttribute attribute : attributes) { + if (Arrays.equals(attribute.getAttributeName(), attributeName)) { + return attribute; } } return null; diff --git a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/XZCompressor.java b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/XZCompressor.java index 9a1779f5b..f0a0fa94b 100644 --- a/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/XZCompressor.java +++ b/bundles/org.eclipse.equinox.p2.repository.tools/src/org/eclipse/equinox/p2/internal/repository/tools/XZCompressor.java @@ -120,8 +120,8 @@ public class XZCompressor { } private void deleteFiles() { - for (Iterator<File> iterator = filesToDelete.iterator(); iterator.hasNext();) { - iterator.next().delete(); + for (File file : filesToDelete) { + file.delete(); } } diff --git a/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java b/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java index 484a0447e..f3586b31b 100644 --- a/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java +++ b/bundles/org.eclipse.equinox.p2.tests.verifier/src/org/eclipse/equinox/internal/p2/tests/verifier/VerifierApplication.java @@ -150,8 +150,8 @@ public class VerifierApplication implements IApplication { for (StringTokenizer tokenizer = new StringTokenizer(list, ","); tokenizer.hasMoreTokens();) ignoreResolved.add(tokenizer.nextToken().trim()); } - for (Iterator<String> iter = ignoreResolved.iterator(); iter.hasNext();) { - if (bundle.equals(iter.next())) + for (String string : ignoreResolved) { + if (bundle.equals(string)) return false; } return true; @@ -203,8 +203,8 @@ public class VerifierApplication implements IApplication { } MultiStatus result = new MultiStatus(Activator.PLUGIN_ID, IStatus.OK, "Problems checking resolved bundles.", null); //$NON-NLS-1$ - for (Iterator<IStatus> iter = allProblems.iterator(); iter.hasNext();) - result.add(iter.next()); + for (IStatus status : allProblems) + result.add(status); return result; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java index 635433a54..0ea3b7394 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/TestArtifactRepository.java @@ -239,8 +239,7 @@ public class TestArtifactRepository implements IArtifactRepository { @Override public void removeDescriptor(IArtifactKey key, IProgressMonitor monitor) { ArrayList<IArtifactDescriptor> removeList = new ArrayList<>(); - for (Iterator<IArtifactDescriptor> iterator = repo.keySet().iterator(); iterator.hasNext();) { - IArtifactDescriptor descriptor = iterator.next(); + for (IArtifactDescriptor descriptor : repo.keySet()) { if (descriptor.getArtifactKey().equals(key)) removeList.add(descriptor); } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootIUActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootIUActionTest.java index f8196c566..6d2ba8201 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootIUActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/publisher/actions/RootIUActionTest.java @@ -300,8 +300,8 @@ public class RootIUActionTest extends ActionTest { } private boolean contains(Collection<IRequirement> required, String iu) { - for (Iterator<IRequirement> iterator = required.iterator(); iterator.hasNext();) { - IRequiredCapability req = (IRequiredCapability) iterator.next(); + for (IRequirement requirement : required) { + IRequiredCapability req = (IRequiredCapability) requirement; if (req.getName().equalsIgnoreCase(iu)) return true; } diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java index bbfa514b2..c75a95bb9 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/SiteXMLActionTest.java @@ -87,8 +87,7 @@ public class SiteXMLActionTest extends AbstractProvisioningTest { Collection<IRepositoryReference> references = metadataRepository.getReferences(); assertEquals("1.0", 2, references.size()); boolean metadataFound = false, artifactFound = false; - for (Iterator<IRepositoryReference> it = references.iterator(); it.hasNext();) { - IRepositoryReference ref = it.next(); + for (IRepositoryReference ref : references) { assertEquals("1.1", "http://download.eclipse.org/eclipse/updates/3.5", ref.getLocation().toString()); assertEquals("1.2", IRepository.ENABLED, ref.getOptions()); assertEquals("1.3", "Eclipse Project Update Site", ref.getNickname()); diff --git a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java index 368e46f9f..a3204eb7d 100644 --- a/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java +++ b/bundles/org.eclipse.equinox.p2.tests/src/org/eclipse/equinox/p2/tests/updatesite/UpdateSiteTest.java @@ -23,7 +23,6 @@ import java.lang.reflect.Field; import java.net.URI; import java.net.URISyntaxException; import java.util.Collection; -import java.util.Iterator; import java.util.Map; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -654,9 +653,8 @@ public class UpdateSiteTest extends AbstractProvisioningTest { IQueryResult<IInstallableUnit> result = metadataRepo.query(query, null); assertEquals("1.0", 1, queryResultSize(result)); IInstallableUnit featureIU = result.iterator().next(); - Collection<IRequirement> required = featureIU.getRequirements(); - for (Iterator<IRequirement> iterator = required.iterator(); iterator.hasNext();) { - IRequiredCapability req = (IRequiredCapability) iterator.next(); + for (IRequirement requirement : featureIU.getRequirements()) { + IRequiredCapability req = (IRequiredCapability) requirement; if (req.getName().equals("org.eclipse.ui.ide")) { assertEquals("2.0", VersionRange.emptyRange, req.getRange()); } diff --git a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/SelectionProviderAdapter.java b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/SelectionProviderAdapter.java index b645084ca..39d91109d 100644 --- a/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/SelectionProviderAdapter.java +++ b/bundles/org.eclipse.equinox.p2.ui.discovery/src/org/eclipse/equinox/internal/p2/ui/discovery/util/SelectionProviderAdapter.java @@ -20,8 +20,8 @@ import org.eclipse.jface.util.SafeRunnable; import org.eclipse.jface.viewers.*; /** - * Provides an simple implementation of {@link ISelectionProvider} that propagates selection events to registered - * listeners. + * Provides an simple implementation of {@link ISelectionProvider} that + * propagates selection events to registered listeners. * * @author Steffen Pingel */ @@ -30,10 +30,10 @@ public class SelectionProviderAdapter extends EventManager implements ISelection private ISelection selection; /** - * Constructs a <code>SelectionProviderAdapter</code> and initializes the selection to <code>selection</code>. + * Constructs a <code>SelectionProviderAdapter</code> and initializes the + * selection to <code>selection</code>. * - * @param selection - * the initial selection + * @param selection the initial selection * @see #setSelection(ISelection) */ public SelectionProviderAdapter(ISelection selection) { @@ -41,7 +41,8 @@ public class SelectionProviderAdapter extends EventManager implements ISelection } /** - * Constructs a <code>SelectionProviderAdapter</code> with a <code>null</code> selection. + * Constructs a <code>SelectionProviderAdapter</code> with a <code>null</code> + * selection. */ public SelectionProviderAdapter() { } @@ -64,13 +65,12 @@ public class SelectionProviderAdapter extends EventManager implements ISelection @Override public void selectionChanged(final SelectionChangedEvent event) { this.selection = event.getSelection(); - Object[] listeners = getListeners(); - for (int i = 0; i < listeners.length; ++i) { - final ISelectionChangedListener listener = (ISelectionChangedListener) listeners[i]; + for (Object listener : getListeners()) { + final ISelectionChangedListener selectionChangedListener = (ISelectionChangedListener) listener; SafeRunner.run(new SafeRunnable() { @Override public void run() { - listener.selectionChanged(event); + selectionChangedListener.selectionChanged(event); } }); } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateManagerCompatibility.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateManagerCompatibility.java index ab481eddd..51ee1ac96 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateManagerCompatibility.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/UpdateManagerCompatibility.java @@ -16,7 +16,6 @@ package org.eclipse.equinox.internal.p2.ui; import java.io.*; import java.net.URI; import java.net.URISyntaxException; -import java.util.Iterator; import java.util.Vector; import javax.xml.parsers.*; import org.eclipse.core.runtime.*; @@ -134,8 +133,7 @@ public class UpdateManagerCompatibility { writer = new PrintWriter(osw); writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$ writer.println("<bookmarks>"); //$NON-NLS-1$ - for (int i = 0; i < bookmarks.size(); i++) { - Object obj = bookmarks.get(i); + for (MetadataRepositoryElement obj : bookmarks) { writeObject(" ", obj, writer); //$NON-NLS-1$ } } catch (IOException e) { @@ -173,8 +171,7 @@ public class UpdateManagerCompatibility { public static IStatus getInstallHandlerStatus(IProvisioningPlan plan) { IQueryResult<IInstallableUnit> result = plan.getAdditions().query(QueryUtil.createIUAnyQuery(), null); - for (Iterator<IInstallableUnit> iterator = result.iterator(); iterator.hasNext();) { - IInstallableUnit iu = iterator.next(); + for (IInstallableUnit iu : result) { if (iu != null && iu.getProperty(ECLIPSE_INSTALL_HANDLER_PROP) != null) return new Status(IStatus.ERROR, ProvUIActivator.PLUGIN_ID, NLS.bind(ProvUIMessages.UpdateManagerCompatibility_ItemRequiresUpdateManager, iu.getId())); } @@ -213,8 +210,8 @@ public class UpdateManagerCompatibility { public static void writeBookmarkFile(String filename, MetadataRepositoryElement[] sites) { Vector<MetadataRepositoryElement> bookmarks = new Vector<>(sites.length); - for (int i = 0; i < sites.length; i++) - bookmarks.add(sites[i]); + for (MetadataRepositoryElement site : sites) + bookmarks.add(site); store(filename, bookmarks); } diff --git a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java index 8088e8f18..41af0500f 100644 --- a/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java +++ b/bundles/org.eclipse.equinox.p2.ui/src/org/eclipse/equinox/internal/p2/ui/ValidationDialogServiceUI.java @@ -133,8 +133,8 @@ public class ValidationDialogServiceUI extends UIServices { private IStatus createStatus() { MultiStatus parent = new MultiStatus(ProvUIActivator.PLUGIN_ID, 0, ProvUIMessages.ServiceUI_unsigned_message, null); - for (int i = 0; i < unsignedDetail.length; i++) { - parent.add(new Status(IStatus.WARNING, ProvUIActivator.PLUGIN_ID, unsignedDetail[i])); + for (String element : unsignedDetail) { + parent.add(new Status(IStatus.WARNING, ProvUIActivator.PLUGIN_ID, element)); } return parent; } diff --git a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java index 2013ac8af..e69d6f71b 100644 --- a/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java +++ b/bundles/org.eclipse.equinox.simpleconfigurator.manipulator/src/org/eclipse/equinox/internal/simpleconfigurator/manipulator/SimpleConfiguratorManipulatorImpl.java @@ -156,8 +156,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani Integer sL0 = bslToList.keySet().iterator().next();// StartLevel == 0; List<BundleInfo> list0 = bslToList.get(sL0); if (sL0.intValue() == 0) - for (Iterator<BundleInfo> ite2 = list0.iterator(); ite2.hasNext();) { - BundleInfo bInfo = ite2.next(); + for (BundleInfo bInfo : list0) { if (isSystemBundle(bInfo.getLocation(), info)) { setToSimpleConfig.add(bInfo); break; @@ -168,28 +167,25 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani List<BundleInfo> list = bslToList.get(sL); if (sL.intValue() < configuratorSL) { - for (Iterator<BundleInfo> ite2 = list.iterator(); ite2.hasNext();) { - BundleInfo bInfo = ite2.next(); + for (BundleInfo bInfo : list) { if (!isSystemBundle(bInfo.getLocation(), info)) setToInitialConfig.add(bInfo); } } else if (sL.intValue() > configuratorSL) { - for (Iterator<BundleInfo> ite2 = list.iterator(); ite2.hasNext();) { - BundleInfo bInfo = ite2.next(); + for (BundleInfo bInfo : list) { if (isPrerequisiteBundles(bInfo.getLocation(), info) - || isSystemFragmentBundle(bInfo.getLocation(), info)) + || isSystemFragmentBundle(bInfo.getLocation(), info)) if (!isSystemBundle(bInfo.getLocation(), info)) setToInitialConfig.add(bInfo); setToSimpleConfig.add(bInfo); } } else { boolean found = false; - for (Iterator<BundleInfo> ite2 = list.iterator(); ite2.hasNext();) { - BundleInfo bInfo = ite2.next(); + for (BundleInfo bInfo : list) { if (found) { if (!isSystemBundle(bInfo.getLocation(), info)) if (isPrerequisiteBundles(bInfo.getLocation(), info) - || isSystemFragmentBundle(bInfo.getLocation(), info)) + || isSystemFragmentBundle(bInfo.getLocation(), info)) setToInitialConfig.add(bInfo); setToSimpleConfig.add(bInfo); continue; @@ -283,8 +279,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani private BundleInfo[] orderingInitialConfig(List<BundleInfo> setToInitialConfig) { List<BundleInfo> notToBeStarted = new LinkedList<>(); List<BundleInfo> toBeStarted = new LinkedList<>(); - for (Iterator<BundleInfo> ite2 = setToInitialConfig.iterator(); ite2.hasNext();) { - BundleInfo bInfo = ite2.next(); + for (BundleInfo bInfo : setToInitialConfig) { if (bInfo.isMarkedAsStarted()) toBeStarted.add(bInfo); else @@ -397,9 +392,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani // convert to FrameworkAdmin BundleInfo Type BundleInfo[] result = new BundleInfo[simpleBundles.size()]; int i = 0; - for (Iterator<org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo> iterator = simpleBundles - .iterator(); iterator.hasNext();) { - org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo simpleInfo = iterator.next(); + for (org.eclipse.equinox.internal.simpleconfigurator.utils.BundleInfo simpleInfo : simpleBundles) { URI location = simpleInfo.getLocation(); if (!location.isAbsolute() && simpleInfo.getBaseLocation() != null) location = URIUtil.makeAbsolute(location, simpleInfo.getBaseLocation()); @@ -573,7 +566,7 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani String[] jvmArgs = manipulator.getLauncherData().getJvmArgs(); for (String jvmArg : jvmArgs) { if (jvmArg.startsWith("-D")) { - //$NON-NLS-1$ + // $NON-NLS-1$ int index = jvmArg.indexOf("="); //$NON-NLS-1$ if (index > 0 && jvmArg.length() > 2) { String key = jvmArg.substring(2, index); @@ -607,27 +600,26 @@ public class SimpleConfiguratorManipulatorImpl implements SimpleConfiguratorMani if (exclusiveInstallation) for (BundleInfo currentBInfo : currentBInfos) { boolean install = false; - for (BundleInfo toInstall1 : toInstall) { - if (currentBInfo.getLocation().equals(toInstall1.getLocation())) { - install = true; - break; + for (BundleInfo toInstall1 : toInstall) { + if (currentBInfo.getLocation().equals(toInstall1.getLocation())) { + install = true; + break; + } + } + if (!install) { + toUninstall.add(currentBInfo); } } - if (!install) { - toUninstall.add(currentBInfo); - } - } for (BundleInfo toInstall1 : toInstall) { try { bundleState.installBundle(toInstall1); - }catch (RuntimeException e) { + } catch (RuntimeException e) { // Ignore } } if (exclusiveInstallation) - for (Iterator<BundleInfo> ite = toUninstall.iterator(); ite.hasNext();) { - BundleInfo bInfo = ite.next(); + for (BundleInfo bInfo : toUninstall) { bundleState.uninstallBundle(bInfo); } diff --git a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java index dfd9496fe..41a0af248 100644 --- a/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java +++ b/bundles/org.eclipse.equinox.simpleconfigurator/src/org/eclipse/equinox/internal/simpleconfigurator/utils/SimpleConfiguratorUtils.java @@ -333,12 +333,12 @@ public class SimpleConfiguratorUtils { public static void transferStreams(List<InputStream> sources, OutputStream destination) throws IOException { destination = new BufferedOutputStream(destination); try { - for (int i = 0; i < sources.size(); i++) { - try (InputStream source = new BufferedInputStream(sources.get(i))) { + for (InputStream source : sources) { + try (InputStream bufferedSource = new BufferedInputStream(source)) { byte[] buffer = new byte[8192]; while (true) { int bytesRead = -1; - if ((bytesRead = source.read(buffer)) == -1) + if ((bytesRead = bufferedSource.read(buffer)) == -1) break; destination.write(buffer, 0, bytesRead); } |