Entry -> Map.Entry

This commit is contained in:
Gintas Grigelionis 2017-11-10 21:52:04 +01:00
parent 3ac2567bca
commit 4272bf28b2
22 changed files with 42 additions and 64 deletions

View File

@ -27,7 +27,6 @@ import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.ivy.core.module.descriptor.Artifact;
import org.apache.ivy.core.module.descriptor.DefaultArtifact;
@ -156,7 +155,7 @@ public class AntWorkspaceResolver extends DataType {
public ResolvedModuleRevision getDependency(DependencyDescriptor dd, ResolveData data)
throws ParseException {
for (Entry<ModuleDescriptor, File> md : getModuleDescriptors().entrySet()) {
for (Map.Entry<ModuleDescriptor, File> md : getModuleDescriptors().entrySet()) {
ResolvedModuleRevision rmr = checkCandidate(dd, md.getKey(),
getProjectName(md.getValue()));
if (rmr != null) {

View File

@ -19,7 +19,6 @@ package org.apache.ivy.ant;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.ivy.core.settings.IvyVariableContainer;
import org.apache.ivy.core.settings.IvyVariableContainerImpl;
@ -74,7 +73,7 @@ class IvyAntVariableContainer extends IvyVariableContainerImpl implements IvyVar
public void updateProject(String id) {
Map<String, String> r = new HashMap<>(super.getVariables());
r.putAll(overwrittenProperties);
for (Entry<String, String> entry : r.entrySet()) {
for (Map.Entry<String, String> entry : r.entrySet()) {
setPropertyIfNotSet(entry.getKey(), entry.getValue());
if (id != null) {
setPropertyIfNotSet(entry.getKey() + "." + id, entry.getValue());

View File

@ -20,7 +20,6 @@ package org.apache.ivy.core.module.id;
import java.lang.ref.WeakReference;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.WeakHashMap;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
@ -264,7 +263,7 @@ public class ModuleRevisionId extends UnmodifiableExtendableItem {
attributes.keySet().removeAll(getExtraAttributes().keySet());
attributes.putAll(getQualifiedExtraAttributes());
for (Entry<String, String> att : attributes.entrySet()) {
for (Map.Entry<String, String> att : attributes.entrySet()) {
String value = att.getValue();
value = (value == null) ? NULL_ENCODE : value;
buf.append(ENCODE_PREFIX).append(att.getKey()).append(ENCODE_SEPARATOR)

View File

@ -22,7 +22,6 @@ import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.ivy.plugins.matcher.MapMatcher;
import org.apache.ivy.util.Checks;
@ -221,12 +220,12 @@ public class ModuleRules<T> {
public void dump(String prefix) {
if (rules.isEmpty()) {
Message.debug(prefix + "NONE");
} else {
for (Entry<MapMatcher, T> entry : rules.entrySet()) {
MapMatcher midm = entry.getKey();
T rule = entry.getValue();
Message.debug(prefix + midm + " -> " + rule);
}
return;
}
for (Map.Entry<MapMatcher, T> entry : rules.entrySet()) {
MapMatcher midm = entry.getKey();
T rule = entry.getValue();
Message.debug(prefix + midm + " -> " + rule);
}
}

View File

@ -29,7 +29,6 @@ import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.ivy.core.IvyContext;
@ -251,7 +250,7 @@ public class PublishEngine {
try {
resolver.beginPublishTransaction(md.getModuleRevisionId(), options.isOverwrite());
// for each declared published artifact in this descriptor, do:
for (Entry<Artifact, File> entry : artifactsFiles.entrySet()) {
for (Map.Entry<Artifact, File> entry : artifactsFiles.entrySet()) {
publish(entry.getKey(), entry.getValue(), resolver, options.isOverwrite());
}
resolver.commitPublishTransaction();

View File

@ -27,7 +27,6 @@ import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.ivy.core.cache.ResolutionCacheManager;
@ -364,7 +363,7 @@ public class ResolveReport {
md.getStatus(), new Date());
// copy namespaces
for (Entry<String, String> ns : md.getExtraAttributesNamespaces().entrySet()) {
for (Map.Entry<String, String> ns : md.getExtraAttributesNamespaces().entrySet()) {
fixedmd.addExtraAttributeNamespace(ns.getKey(), ns.getValue());
}

View File

@ -29,7 +29,6 @@ import java.util.LinkedHashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Stack;
import java.util.regex.Matcher;
@ -909,7 +908,7 @@ public class IvyNode implements Comparable<IvyNode> {
private static Collection<Artifact> findArtifactsMatching(IncludeRule rule,
Map<ArtifactId, Artifact> allArtifacts) {
Collection<Artifact> ret = new ArrayList<>();
for (Entry<ArtifactId, Artifact> entry : allArtifacts.entrySet()) {
for (Map.Entry<ArtifactId, Artifact> entry : allArtifacts.entrySet()) {
if (MatcherHelper.matches(rule.getMatcher(), rule.getId(), entry.getKey())) {
ret.add(entry.getValue());
}

View File

@ -25,7 +25,6 @@ import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.ivy.core.event.EventManager;
import org.apache.ivy.core.module.descriptor.DependencyDescriptor;
@ -98,7 +97,7 @@ public class ResolveData {
if (result == null) {
// search again, now ignore the missing extra attributes
for (Entry<ModuleRevisionId, VisitData> entry : visitData.entrySet()) {
for (Map.Entry<ModuleRevisionId, VisitData> entry : visitData.entrySet()) {
ModuleRevisionId current = entry.getKey();
if (isSubMap(mrid.getAttributes(), current.getAttributes())) {
@ -125,7 +124,7 @@ public class ResolveData {
Map<K, V> smallest = map1Size < map2Size ? map1 : map2;
Map<K, V> largest = map1Size < map2Size ? map2 : map1;
for (Entry<K, V> entry : smallest.entrySet()) {
for (Map.Entry<K, V> entry : smallest.entrySet()) {
if (!largest.containsKey(entry.getKey())) {
return false;
@ -244,9 +243,9 @@ public class ResolveData {
}
void blacklist(IvyNode node) {
Iterator<Entry<ModuleRevisionId, VisitData>> iter = visitData.entrySet().iterator();
Iterator<Map.Entry<ModuleRevisionId, VisitData>> iter = visitData.entrySet().iterator();
while (iter.hasNext()) {
Entry<ModuleRevisionId, VisitData> entry = iter.next();
Map.Entry<ModuleRevisionId, VisitData> entry = iter.next();
if (entry.getValue().getNode() == node && !node.getResolvedId().equals(entry.getKey())) {
// this visit data was associated with the blacklisted node,
// we discard this association
@ -262,7 +261,7 @@ public class ResolveData {
if (node == null) {
// search again, now ignore the extra attributes
// TODO: maybe we should search the node that has at least the same attributes as mrid
for (Entry<ModuleRevisionId, VisitData> entry : visitData.entrySet()) {
for (Map.Entry<ModuleRevisionId, VisitData> entry : visitData.entrySet()) {
ModuleRevisionId current = entry.getKey();
if (current.getModuleId().equals(mrid.getModuleId())
&& current.getRevision().equals(mrid.getRevision())) {

View File

@ -29,7 +29,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.ivy.core.IvyContext;
@ -134,7 +133,7 @@ public class RetrieveEngine {
// do retrieve
long totalCopiedSize = 0;
for (Entry<ArtifactDownloadReport, Set<String>> artifactAndPaths : artifactsToCopy
for (Map.Entry<ArtifactDownloadReport, Set<String>> artifactAndPaths : artifactsToCopy
.entrySet()) {
ArtifactDownloadReport artifact = artifactAndPaths.getKey();
File archive = artifact.getLocalFile();
@ -393,7 +392,7 @@ public class RetrieveEngine {
}
// resolve conflicts if any
for (Entry<String, Set<ArtifactRevisionId>> entry : conflictsMap.entrySet()) {
for (Map.Entry<String, Set<ArtifactRevisionId>> entry : conflictsMap.entrySet()) {
String copyDest = entry.getKey();
Set<ArtifactRevisionId> artifacts = entry.getValue();
Set<String> conflictsConfs = conflictsConfMap.get(copyDest);

View File

@ -25,7 +25,6 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.ivy.core.IvyPatternHelper;
@ -221,7 +220,7 @@ public class SearchEngine {
List<ModuleRevisionId> ret = new ArrayList<>();
Map<String, Object> criteria = new HashMap<>();
for (Entry<String, String> entry : moduleCrit.getAttributes().entrySet()) {
for (Map.Entry<String, String> entry : moduleCrit.getAttributes().entrySet()) {
addMatcher(matcher, entry.getValue(), criteria, entry.getKey());
}
@ -277,7 +276,7 @@ public class SearchEngine {
public ModuleRevisionId[] listModules(DependencyResolver resolver, ModuleRevisionId moduleCrit,
PatternMatcher matcher) {
Map<String, Object> criteria = new HashMap<>();
for (Entry<String, String> entry : moduleCrit.getAttributes().entrySet()) {
for (Map.Entry<String, String> entry : moduleCrit.getAttributes().entrySet()) {
addMatcher(matcher, entry.getValue(), criteria, entry.getKey());
}

View File

@ -111,7 +111,6 @@ import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import static org.apache.ivy.util.StringUtils.splitToArray;
@ -372,7 +371,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
}
public synchronized void typeDefs(Properties p, boolean silentFail) {
for (Entry<Object, Object> entry : p.entrySet()) {
for (Map.Entry<Object, Object> entry : p.entrySet()) {
typeDef(entry.getKey().toString(), entry.getValue().toString(), silentFail);
}
}
@ -631,7 +630,7 @@ public class IvySettings implements SortEngineSettings, PublishEngineSettings, P
*/
public synchronized Map<String, String> substitute(Map<String, String> strings) {
Map<String, String> substituted = new LinkedHashMap<>();
for (Entry<String, String> entry : strings.entrySet()) {
for (Map.Entry<String, String> entry : strings.entrySet()) {
substituted.put(entry.getKey(), substitute(entry.getValue()));
}
return substituted;

View File

@ -27,7 +27,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import java.util.jar.Manifest;
@ -170,7 +169,7 @@ public class BundleInfoAdapter {
}
if (manifest != null) {
for (Entry<Object, Object> entries : manifest.getMainAttributes().entrySet()) {
for (Map.Entry<Object, Object> entries : manifest.getMainAttributes().entrySet()) {
md.addExtraInfo(new ExtraInfoHolder(entries.getKey().toString(), entries.getValue()
.toString()));
}

View File

@ -22,7 +22,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Properties;
import org.apache.ivy.util.Message;
@ -75,7 +74,7 @@ public class ExecutionEnvironmentProfileProvider {
defaultProfilesFile.close();
}
Map<String, ExecutionEnvironmentProfile> profiles = new HashMap<>();
for (Entry<Object, Object> prop : props.entrySet()) {
for (Map.Entry<Object, Object> prop : props.entrySet()) {
String propName = (String) prop.getKey();
if (propName.endsWith(".pkglist")) {
String profileName = propName.substring(0, propName.length() - 8);

View File

@ -21,7 +21,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
public class ManifestHeaderElement {
private List<String> values = new ArrayList<>();
@ -70,7 +69,7 @@ public class ManifestHeaderElement {
if (other.directives.size() != directives.size()) {
return false;
}
for (Entry<String, String> directive : directives.entrySet()) {
for (Map.Entry<String, String> directive : directives.entrySet()) {
if (!directive.getValue().equals(other.directives.get(directive.getKey()))) {
return false;
}
@ -78,7 +77,7 @@ public class ManifestHeaderElement {
if (other.attributes.size() != attributes.size()) {
return false;
}
for (Entry<String, String> attribute : attributes.entrySet()) {
for (Map.Entry<String, String> attribute : attributes.entrySet()) {
if (!attribute.getValue().equals(other.attributes.get(attribute.getKey()))) {
return false;
}
@ -94,10 +93,10 @@ public class ManifestHeaderElement {
}
sb.append(value);
}
for (Entry<String, String> directive : directives.entrySet()) {
for (Map.Entry<String, String> directive : directives.entrySet()) {
sb.append(";").append(directive.getKey()).append(":=").append(directive.getValue());
}
for (Entry<String, String> attribute : attributes.entrySet()) {
for (Map.Entry<String, String> attribute : attributes.entrySet()) {
sb.append(";").append(attribute.getKey()).append("=").append(attribute.getValue());
}
return sb.toString();

View File

@ -27,7 +27,6 @@ import java.text.ParseException;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
import javax.xml.parsers.ParserConfigurationException;
@ -82,7 +81,7 @@ public class P2ArtifactParser implements XMLInputParser {
addChild(new MappingsHandler(), new ChildElementHandler<MappingsHandler>() {
@Override
public void childHandled(MappingsHandler child) {
for (Entry<String, String> entry : child.outputByFilter.entrySet()) {
for (Map.Entry<String, String> entry : child.outputByFilter.entrySet()) {
OSGiFilter filter;
try {
filter = OSGiFilterParser.parse(entry.getKey());
@ -193,7 +192,7 @@ public class P2ArtifactParser implements XMLInputParser {
private String getPattern(P2Artifact p2Artifact, Map<String, String> properties) {
Map<String, String> props = new HashMap<>(properties);
props.put("classifier", p2Artifact.getClassifier());
for (Entry<OSGiFilter, String> pattern : artifactPatterns.entrySet()) {
for (Map.Entry<OSGiFilter, String> pattern : artifactPatterns.entrySet()) {
if (pattern.getKey().eval(props)) {
return pattern.getValue();
}

View File

@ -29,7 +29,6 @@ import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.ivy.core.IvyPatternHelper;
@ -256,7 +255,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
if (requirementStrategy == RequirementStrategy.first) {
Message.warn("Ambiguity for the '" + osgiType + "' requirement "
+ mrid.getName() + ";version=" + mrid.getRevision());
for (Entry<String, List<MDResolvedResource>> entry : matching.entrySet()) {
for (Map.Entry<String, List<MDResolvedResource>> entry : matching.entrySet()) {
Message.warn("\t" + entry.getKey());
for (MDResolvedResource c : entry.getValue()) {
Message.warn("\t\t" + c.getRevision()
@ -266,7 +265,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
} else if (requirementStrategy == RequirementStrategy.noambiguity) {
Message.error("Ambiguity for the '" + osgiType + "' requirement "
+ mrid.getName() + ";version=" + mrid.getRevision());
for (Entry<String, List<MDResolvedResource>> entry : matching.entrySet()) {
for (Map.Entry<String, List<MDResolvedResource>> entry : matching.entrySet()) {
Message.error("\t" + entry.getKey());
for (MDResolvedResource c : entry.getValue()) {
Message.error("\t\t" + c.getRevision()
@ -386,7 +385,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
// no revision, all match then
capabilityValues.addAll(moduleByCapabilityValue.keySet());
} else {
for (Entry<String, Set<ModuleDescriptor>> entry : moduleByCapabilityValue.entrySet()) {
for (Map.Entry<String, Set<ModuleDescriptor>> entry : moduleByCapabilityValue.entrySet()) {
boolean moduleMatchRev = false;
for (ModuleDescriptor md : entry.getValue()) {
moduleMatchRev = rev.equals(md.getRevision());
@ -413,7 +412,7 @@ public abstract class AbstractOSGiResolver extends BasicResolver {
private Set<Map<String, String>> listTokenValues(Set<String> tokens,
Map<String, Object> criteria) {
Map<String, String> stringCriteria = new HashMap<>();
for (Entry<String, Object> entry : criteria.entrySet()) {
for (Map.Entry<String, Object> entry : criteria.entrySet()) {
Object value = entry.getValue();
if (!(value instanceof String)) {
// no support for matcher for now

View File

@ -20,7 +20,6 @@ package org.apache.ivy.plugins.matcher;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public class MapMatcher {
private Map<String, Matcher> matchers = new HashMap<>();
@ -32,7 +31,7 @@ public class MapMatcher {
public MapMatcher(Map<String, String> attributes, PatternMatcher pm) {
this.attributes = attributes;
this.pm = pm;
for (Entry<String, String> entry : attributes.entrySet()) {
for (Map.Entry<String, String> entry : attributes.entrySet()) {
String value = entry.getValue();
if (value != null) {
matchers.put(entry.getKey(), pm.getMatcher(value));
@ -41,7 +40,7 @@ public class MapMatcher {
}
public boolean matches(Map<String, String> m) {
for (Entry<String, Matcher> entry : matchers.entrySet()) {
for (Map.Entry<String, Matcher> entry : matchers.entrySet()) {
Matcher matcher = entry.getValue();
String value = m.get(entry.getKey());
if ((value == null) || !matcher.matches(value)) {

View File

@ -24,7 +24,6 @@ import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.core.module.descriptor.Artifact;
@ -466,7 +465,7 @@ public final class XmlModuleDescriptorWriter {
}
out.print("<");
out.print(extraInfo.getName());
for (Entry<String, String> entry : extraInfo.getAttributes().entrySet()) {
for (Map.Entry<String, String> entry : extraInfo.getAttributes().entrySet()) {
out.print(String.format(" %s=\"%s\"", entry.getKey(), entry.getValue()));
}
boolean requireClosingTag = false;

View File

@ -27,7 +27,6 @@ import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Set;
import org.apache.ivy.core.IvyPatternHelper;
@ -199,7 +198,7 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
Set<String> tokenSet = new HashSet<>(Arrays.asList(tokens));
Map<String, String> tokenValues = new HashMap<>();
for (Entry<String, Object> entry : criteria.entrySet()) {
for (Map.Entry<String, Object> entry : criteria.entrySet()) {
Object value = entry.getValue();
if (value instanceof String) {
tokenValues.put(entry.getKey(), (String) value);

View File

@ -25,7 +25,6 @@ import java.util.LinkedList;
import java.util.List;
import java.util.ListIterator;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.ivy.util.StringUtils;
@ -100,7 +99,7 @@ public class CommandLineParser {
}
// print options help
for (Entry<String, List<Option>> entry : categories.entrySet()) {
for (Map.Entry<String, List<Option>> entry : categories.entrySet()) {
pw.println("==== " + entry.getKey());
for (Option option : entry.getValue()) {
if (option.isDeprecated() && !showDeprecated) {

View File

@ -21,7 +21,6 @@ import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import org.apache.ivy.plugins.parser.ParserSettings;
import org.xml.sax.Attributes;
@ -75,7 +74,7 @@ public final class ExtendableItemHelper {
public static void fillExtraAttributes(ParserSettings settings, DefaultExtendableItem item,
Attributes attributes, List<String> ignoredAttNames) {
Map<String, String> att = getExtraAttributes(settings, attributes, ignoredAttNames);
for (Entry<String, String> entry : att.entrySet()) {
for (Map.Entry<String, String> entry : att.entrySet()) {
item.setExtraAttribute(entry.getKey(), entry.getValue());
}
}

View File

@ -20,7 +20,6 @@ package org.apache.ivy.util.extendable;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
public class UnmodifiableExtendableItem implements ExtendableItem {
private final Map<String, String> attributes = new HashMap<>();
@ -48,7 +47,7 @@ public class UnmodifiableExtendableItem implements ExtendableItem {
this.attributes.putAll(stdAttributes);
}
if (extraAttributes != null) {
for (Entry<String, String> extraAtt : extraAttributes.entrySet()) {
for (Map.Entry<String, String> extraAtt : extraAttributes.entrySet()) {
setExtraAttribute(extraAtt.getKey(), extraAtt.getValue());
}
}