You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by ja...@apache.org on 2017/07/01 14:49:37 UTC
[2/4] ant-ivy git commit: Generics and Java 7 syntax in plugins
package
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java b/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java
index 5c3a9c0..4939931 100644
--- a/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java
+++ b/src/java/org/apache/ivy/plugins/repository/ssh/SshRepository.java
@@ -87,12 +87,7 @@ public class SshRepository extends AbstractSshBasedRepository {
Scp.FileInfo fileInfo = myCopy.getFileinfo(new URI(source).getPath());
result = new SshResource(this, source, true, fileInfo.getLength(),
fileInfo.getLastModified());
- } catch (IOException e) {
- if (session != null) {
- releaseSession(session, source);
- }
- result = new SshResource();
- } catch (URISyntaxException e) {
+ } catch (IOException | URISyntaxException e) {
if (session != null) {
releaseSession(session, source);
}
@@ -123,8 +118,8 @@ public class SshRepository extends AbstractSshBasedRepository {
try {
channel.connect();
- } catch (JSchException e1) {
- throw (IOException) new IOException("Channel connection problems").initCause(e1);
+ } catch (JSchException jsche) {
+ throw new IOException("Channel connection problems", jsche);
}
byte[] buffer = new byte[BUFFER_SIZE];
@@ -163,9 +158,9 @@ public class SshRepository extends AbstractSshBasedRepository {
*
* @see org.apache.ivy.repository.Repository#list(java.lang.String)
*/
- public List list(String parent) throws IOException {
+ public List<String> list(String parent) throws IOException {
Message.debug("SShRepository:list called: " + parent);
- ArrayList result = new ArrayList();
+ ArrayList<String> result = new ArrayList<>();
Session session = null;
ChannelExec channel = null;
session = getSession(parent);
@@ -174,9 +169,7 @@ public class SshRepository extends AbstractSshBasedRepository {
try {
parentUri = new URI(parent);
} catch (URISyntaxException e) {
- IOException ioe = new IOException("The uri '" + parent + "' is not valid!");
- ioe.initCause(e);
- throw ioe;
+ throw new IOException("The uri '" + parent + "' is not valid!", e);
}
String fullCmd = replaceArgument(listCommand, parentUri.getPath());
channel.setCommand(fullCmd);
@@ -222,7 +215,7 @@ public class SshRepository extends AbstractSshBasedRepository {
*/
private String replaceArgument(String command, String argument) {
String fullCmd;
- if (command.indexOf(ARGUMENT_PLACEHOLDER) == -1) {
+ if (!command.contains(ARGUMENT_PLACEHOLDER)) {
fullCmd = command + " " + argument;
} else {
fullCmd = command.replaceAll(ARGUMENT_PLACEHOLDER, argument);
@@ -243,9 +236,7 @@ public class SshRepository extends AbstractSshBasedRepository {
try {
destinationUri = new URI(destination);
} catch (URISyntaxException e) {
- IOException ioe = new IOException("The uri '" + destination + "' is not valid!");
- ioe.initCause(e);
- throw ioe;
+ throw new IOException("The uri '" + destination + "' is not valid!", e);
}
try {
@@ -355,9 +346,7 @@ public class SshRepository extends AbstractSshBasedRepository {
try {
sourceUri = new URI(source);
} catch (URISyntaxException e) {
- IOException ioe = new IOException("The uri '" + source + "' is not valid!");
- ioe.initCause(e);
- throw ioe;
+ throw new IOException("The uri '" + source + "' is not valid!", e);
}
try {
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java b/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java
index 417b9a5..4a9fe38 100644
--- a/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java
+++ b/src/java/org/apache/ivy/plugins/repository/url/ChainedRepository.java
@@ -19,7 +19,6 @@ package org.apache.ivy.plugins.repository.url;
import java.io.File;
import java.io.IOException;
-import java.util.Iterator;
import java.util.List;
import org.apache.ivy.plugins.repository.AbstractRepository;
@@ -30,16 +29,14 @@ import org.apache.ivy.util.Message;
public class ChainedRepository extends AbstractRepository {
- private List/* Repository */repositories;
+ private List<Repository> repositories;
- public void setRepositories(List/* Repository */repositories) {
+ public void setRepositories(List<Repository> repositories) {
this.repositories = repositories;
}
public Resource getResource(String source) throws IOException {
- Iterator it = repositories.iterator();
- while (it.hasNext()) {
- Repository repository = (Repository) it.next();
+ for (Repository repository : repositories) {
logTry(repository);
try {
Resource r = repository.getResource(source);
@@ -56,9 +53,7 @@ public class ChainedRepository extends AbstractRepository {
}
public void get(String source, File destination) throws IOException {
- Iterator it = repositories.iterator();
- while (it.hasNext()) {
- Repository repository = (Repository) it.next();
+ for (Repository repository : repositories) {
logTry(repository);
boolean ok = false;
try {
@@ -75,13 +70,11 @@ public class ChainedRepository extends AbstractRepository {
throw newIOEFail("copy " + source + " into " + destination);
}
- public List list(String parent) throws IOException {
- Iterator it = repositories.iterator();
- while (it.hasNext()) {
- Repository repository = (Repository) it.next();
+ public List<String> list(String parent) throws IOException {
+ for (Repository repository : repositories) {
logTry(repository);
try {
- List list = repository.list(parent);
+ List<String> list = repository.list(parent);
if (list != null) {
logSuccess(repository);
return list;
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/url/URLRepository.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/url/URLRepository.java b/src/java/org/apache/ivy/plugins/repository/url/URLRepository.java
index 2897642..d045c60 100644
--- a/src/java/org/apache/ivy/plugins/repository/url/URLRepository.java
+++ b/src/java/org/apache/ivy/plugins/repository/url/URLRepository.java
@@ -26,7 +26,6 @@ import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
-import java.util.ListIterator;
import java.util.Map;
import org.apache.ivy.plugins.repository.AbstractRepository;
@@ -39,10 +38,10 @@ import org.apache.ivy.util.url.ApacheURLLister;
public class URLRepository extends AbstractRepository {
private RepositoryCopyProgressListener progress = new RepositoryCopyProgressListener(this);
- private Map resourcesCache = new HashMap();
+ private final Map<String, Resource> resourcesCache = new HashMap<>();
public Resource getResource(String source) throws IOException {
- Resource res = (Resource) resourcesCache.get(source);
+ Resource res = resourcesCache.get(source);
if (res == null) {
res = new URLResource(new URL(source));
resourcesCache.put(source, res);
@@ -56,13 +55,10 @@ public class URLRepository extends AbstractRepository {
Resource res = getResource(source);
long totalLength = res.getContentLength();
if (totalLength > 0) {
- progress.setTotalLength(new Long(totalLength));
+ progress.setTotalLength(totalLength);
}
FileUtil.copy(new URL(source), destination, progress);
- } catch (IOException ex) {
- fireTransferError(ex);
- throw ex;
- } catch (RuntimeException ex) {
+ } catch (IOException | RuntimeException ex) {
fireTransferError(ex);
throw ex;
} finally {
@@ -79,13 +75,10 @@ public class URLRepository extends AbstractRepository {
try {
long totalLength = source.length();
if (totalLength > 0) {
- progress.setTotalLength(new Long(totalLength));
+ progress.setTotalLength(totalLength);
}
FileUtil.copy(source, new URL(destination), progress);
- } catch (IOException ex) {
- fireTransferError(ex);
- throw ex;
- } catch (RuntimeException ex) {
+ } catch (IOException | RuntimeException ex) {
fireTransferError(ex);
throw ex;
} finally {
@@ -95,13 +88,12 @@ public class URLRepository extends AbstractRepository {
private ApacheURLLister lister = new ApacheURLLister();
- public List list(String parent) throws IOException {
+ public List<String> list(String parent) throws IOException {
if (parent.startsWith("http")) {
- List urls = lister.listAll(new URL(parent));
+ List<URL> urls = lister.listAll(new URL(parent));
if (urls != null) {
- List ret = new ArrayList(urls.size());
- for (ListIterator iter = urls.listIterator(); iter.hasNext();) {
- URL url = (URL) iter.next();
+ List<String> ret = new ArrayList<>(urls.size());
+ for (URL url : urls) {
ret.add(url.toExternalForm());
}
return ret;
@@ -116,18 +108,16 @@ public class URLRepository extends AbstractRepository {
path = uri.getPath();
}
} catch (URISyntaxException e) {
- IOException ioe = new IOException("Couldn't list content of '" + parent + "'");
- ioe.initCause(e);
- throw ioe;
+ throw new IOException("Couldn't list content of '" + parent + "'", e);
}
File file = new File(path);
if (file.exists() && file.isDirectory()) {
String[] files = file.list();
- List ret = new ArrayList(files.length);
+ List<String> ret = new ArrayList<>(files.length);
URL context = path.endsWith("/") ? new URL(parent) : new URL(parent + "/");
- for (int i = 0; i < files.length; i++) {
- ret.add(new URL(context, files[i]).toExternalForm());
+ for (String fileName : files) {
+ ret.add(new URL(context, fileName).toExternalForm());
}
return ret;
} else {
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/vfs/VfsRepository.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/vfs/VfsRepository.java b/src/java/org/apache/ivy/plugins/repository/vfs/VfsRepository.java
index f086822..b220250 100644
--- a/src/java/org/apache/ivy/plugins/repository/vfs/VfsRepository.java
+++ b/src/java/org/apache/ivy/plugins/repository/vfs/VfsRepository.java
@@ -88,8 +88,8 @@ public class VfsRepository extends AbstractRepository {
Message.verbose("Available VFS schemes...");
String[] schemes = result.getSchemes();
Arrays.sort(schemes);
- for (int i = 0; i < schemes.length; i++) {
- Message.verbose("VFS Supported Scheme: " + schemes[i]);
+ for (String scheme : schemes) {
+ Message.verbose("VFS Supported Scheme: " + scheme);
}
} catch (FileSystemException e) {
/*
@@ -100,9 +100,7 @@ public class VfsRepository extends AbstractRepository {
*/
Message.error("Unable to initialize VFS repository manager!");
Message.error(e.getLocalizedMessage());
- IOException error = new IOException(e.getLocalizedMessage());
- error.initCause(e);
- throw error;
+ throw new IOException(e.getLocalizedMessage(), e);
}
return result;
@@ -148,10 +146,7 @@ public class VfsRepository extends AbstractRepository {
+ ": no content found");
}
FileUtil.copy(content.getInputStream(), destination, progress);
- } catch (IOException ex) {
- fireTransferError(ex);
- throw ex;
- } catch (RuntimeException ex) {
+ } catch (IOException | RuntimeException ex) {
fireTransferError(ex);
throw ex;
}
@@ -168,8 +163,8 @@ public class VfsRepository extends AbstractRepository {
* on failure.
* @see "Supported File Systems in the jakarta-commons-vfs documentation"
*/
- public List list(String vfsURI) throws IOException {
- ArrayList list = new ArrayList();
+ public List<String> list(String vfsURI) throws IOException {
+ ArrayList<String> list = new ArrayList<>();
Message.debug("list called for URI" + vfsURI);
FileObject resourceImpl = getVFSManager().resolveFile(vfsURI);
Message.debug("resourceImpl=" + resourceImpl.toString());
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/repository/vsftp/VsftpRepository.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/repository/vsftp/VsftpRepository.java b/src/java/org/apache/ivy/plugins/repository/vsftp/VsftpRepository.java
index 59b99e7..861fe3c 100644
--- a/src/java/org/apache/ivy/plugins/repository/vsftp/VsftpRepository.java
+++ b/src/java/org/apache/ivy/plugins/repository/vsftp/VsftpRepository.java
@@ -217,7 +217,7 @@ public class VsftpRepository extends AbstractRepository {
}
}
- public List list(String parent) throws IOException {
+ public List<String> list(String parent) throws IOException {
initIvy();
try {
if (!parent.endsWith("/")) {
@@ -228,7 +228,7 @@ public class VsftpRepository extends AbstractRepository {
return null;
}
String[] lines = response.split("\n");
- List ret = new ArrayList(lines.length);
+ List<String> ret = new ArrayList<>(lines.length);
for (int i = 0; i < lines.length; i++) {
while (lines[i].endsWith("\r") || lines[i].endsWith("\n")) {
lines[i] = lines[i].substring(0, lines[i].length() - 1);
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java b/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java
index e493cce..5a3765b 100644
--- a/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/AbstractPatternsBasedResolver.java
@@ -48,9 +48,9 @@ import org.apache.ivy.util.Message;
*/
public abstract class AbstractPatternsBasedResolver extends BasicResolver {
- private List<String> ivyPatterns = new ArrayList<String>();
+ private List<String> ivyPatterns = new ArrayList<>();
- private List<String> artifactPatterns = new ArrayList<String>();
+ private List<String> artifactPatterns = new ArrayList<>();
private boolean m2compatible = false;
@@ -89,8 +89,8 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
protected ResolvedResource findResourceUsingPatterns(ModuleRevisionId moduleRevision,
List<String> patternList, Artifact artifact, ResourceMDParser rmdparser, Date date) {
- List<ResolvedResource> resolvedResources = new ArrayList<ResolvedResource>();
- Set<String> foundRevisions = new HashSet<String>();
+ List<ResolvedResource> resolvedResources = new ArrayList<>();
+ Set<String> foundRevisions = new HashSet<>();
boolean dynamic = getSettings().getVersionMatcher().isDynamic(moduleRevision);
boolean stop = false;
for (Iterator<String> iter = patternList.iterator(); iter.hasNext() && !stop;) {
@@ -121,7 +121,7 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
@Override
protected Collection<String> findNames(Map<String, String> tokenValues, String token) {
- Collection<String> names = new HashSet<String>();
+ Collection<String> names = new HashSet<>();
names.addAll(findIvyNames(tokenValues, token));
if (isAllownomd()) {
names.addAll(findArtifactNames(tokenValues, token));
@@ -130,8 +130,8 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
}
protected Collection<String> findIvyNames(Map<String, String> tokenValues, String token) {
- Collection<String> names = new HashSet<String>();
- tokenValues = new HashMap<String, String>(tokenValues);
+ Collection<String> names = new HashSet<>();
+ tokenValues = new HashMap<>(tokenValues);
tokenValues.put(IvyPatternHelper.ARTIFACT_KEY, "ivy");
tokenValues.put(IvyPatternHelper.TYPE_KEY, "ivy");
tokenValues.put(IvyPatternHelper.EXT_KEY, "xml");
@@ -144,8 +144,8 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
}
protected Collection<String> findArtifactNames(Map<String, String> tokenValues, String token) {
- Collection<String> names = new HashSet<String>();
- tokenValues = new HashMap<String, String>(tokenValues);
+ Collection<String> names = new HashSet<>();
+ tokenValues = new HashMap<>(tokenValues);
tokenValues
.put(IvyPatternHelper.ARTIFACT_KEY, tokenValues.get(IvyPatternHelper.MODULE_KEY));
tokenValues.put(IvyPatternHelper.TYPE_KEY, "jar");
@@ -160,11 +160,11 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
@Override
public Map<String, String>[] listTokenValues(String[] tokens, Map<String, Object> criteria) {
- Set<Map<String, String>> result = new LinkedHashSet<Map<String, String>>();
+ Set<Map<String, String>> result = new LinkedHashSet<>();
// use ivy patterns
List<String> ivyPatterns = getIvyPatterns();
- Map<String, Object> subcriteria = new HashMap<String, Object>(criteria);
+ Map<String, Object> subcriteria = new HashMap<>(criteria);
subcriteria.put(IvyPatternHelper.TYPE_KEY, "ivy");
subcriteria.put(IvyPatternHelper.EXT_KEY, getModuleDescriptorExtension());
if (isM2compatible()) {
@@ -176,7 +176,7 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
if (isAllownomd()) {
List<String> artifactPatterns = getArtifactPatterns();
- subcriteria = new HashMap<String, Object>(criteria);
+ subcriteria = new HashMap<>(criteria);
subcriteria.put(IvyPatternHelper.TYPE_KEY, "jar");
subcriteria.put(IvyPatternHelper.EXT_KEY, "jar");
if (isM2compatible()) {
@@ -196,10 +196,10 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
private Set<Map<String, String>> resolveTokenValues(String[] tokens, String pattern,
Map<String, Object> criteria, boolean noMd) {
- Set<Map<String, String>> result = new LinkedHashSet<Map<String, String>>();
- Set<String> tokenSet = new HashSet<String>(Arrays.asList(tokens));
+ Set<Map<String, String>> result = new LinkedHashSet<>();
+ Set<String> tokenSet = new HashSet<>(Arrays.asList(tokens));
- Map<String, String> tokenValues = new HashMap<String, String>();
+ Map<String, String> tokenValues = new HashMap<>();
for (Entry<String, Object> entry : criteria.entrySet()) {
String key = entry.getKey();
Object value = entry.getValue();
@@ -235,7 +235,7 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
return result;
}
- List<String> vals = new ArrayList<String>(Arrays.asList(values));
+ List<String> vals = new ArrayList<>(Arrays.asList(values));
filterNames(vals);
for (String value : vals) {
@@ -247,7 +247,7 @@ public abstract class AbstractPatternsBasedResolver extends BasicResolver {
String moreResolvedPattern = IvyPatternHelper.substituteTokens(
partiallyResolvedPattern, tokenValues);
- Map<String, Object> newCriteria = new HashMap<String, Object>(criteria);
+ Map<String, Object> newCriteria = new HashMap<>(criteria);
newCriteria.put(token, value);
if (noMd && "artifact".equals(token)) {
newCriteria.put("module", value);
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java b/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
index ed8a3d9..1d66f45 100644
--- a/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/AbstractResolver.java
@@ -604,7 +604,7 @@ public abstract class AbstractResolver implements DependencyResolver, HasLatestS
return AbstractResolver.this.getSettings().resolveFile(filename);
}
- public Map substitute(Map strings) {
+ public Map<String, String> substitute(Map<String, String> strings) {
return AbstractResolver.this.getSettings().substitute(strings);
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/AbstractWorkspaceResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/AbstractWorkspaceResolver.java b/src/java/org/apache/ivy/plugins/resolver/AbstractWorkspaceResolver.java
index 016bd99..91991f4 100644
--- a/src/java/org/apache/ivy/plugins/resolver/AbstractWorkspaceResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/AbstractWorkspaceResolver.java
@@ -76,51 +76,55 @@ public abstract class AbstractWorkspaceResolver extends AbstractResolver {
// search a match on the organization and the module name
- if (org.equals(BundleInfo.BUNDLE_TYPE)) {
- // looking for an OSGi bundle via its symbolic name
- String sn = md.getExtraInfoContentByTagName("Bundle-SymbolicName");
- if (sn == null || !module.equals(sn)) {
- // not found, skip to next
- return null;
- }
- } else if (org.equals(BundleInfo.PACKAGE_TYPE)) {
- // looking for an OSGi bundle via its exported package
- String exportedPackages = md.getExtraInfoContentByTagName("Export-Package");
- if (exportedPackages == null) {
- // not found, skip to next
- return null;
- }
- boolean found = false;
- String version = null;
- ManifestHeaderValue exportElements;
- try {
- exportElements = new ManifestHeaderValue(exportedPackages);
- } catch (ParseException e) {
- // wrong OSGi header: skip it
- return null;
- }
- for (ManifestHeaderElement exportElement : exportElements.getElements()) {
- if (exportElement.getValues().contains(module)) {
- found = true;
- version = exportElement.getAttributes().get("version");
- break;
+ switch (org) {
+ case BundleInfo.BUNDLE_TYPE:
+ // looking for an OSGi bundle via its symbolic name
+ String sn = md.getExtraInfoContentByTagName("Bundle-SymbolicName");
+ if (sn == null || !module.equals(sn)) {
+ // not found, skip to next
+ return null;
}
- }
- if (!found) {
- // not found, skip to next
- return null;
- }
- if (version == null) {
- // no version means anything can match. Let's trick the version matcher by
- // setting the exact expected version
- version = dependencyMrid.getRevision();
- }
- md.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(org, module, version));
- } else {
- if (!candidateMrid.getModuleId().equals(dependencyMrid.getModuleId())) {
- // it doesn't match org#module, skip to next
- return null;
- }
+ break;
+ case BundleInfo.PACKAGE_TYPE:
+ // looking for an OSGi bundle via its exported package
+ String exportedPackages = md.getExtraInfoContentByTagName("Export-Package");
+ if (exportedPackages == null) {
+ // not found, skip to next
+ return null;
+ }
+ boolean found = false;
+ String version = null;
+ ManifestHeaderValue exportElements;
+ try {
+ exportElements = new ManifestHeaderValue(exportedPackages);
+ } catch (ParseException e) {
+ // wrong OSGi header: skip it
+ return null;
+ }
+ for (ManifestHeaderElement exportElement : exportElements.getElements()) {
+ if (exportElement.getValues().contains(module)) {
+ found = true;
+ version = exportElement.getAttributes().get("version");
+ break;
+ }
+ }
+ if (!found) {
+ // not found, skip to next
+ return null;
+ }
+ if (version == null) {
+ // no version means anything can match. Let's trick the version matcher by
+ // setting the exact expected version
+ version = dependencyMrid.getRevision();
+ }
+ md.setResolvedModuleRevisionId(ModuleRevisionId.newInstance(org, module, version));
+ break;
+ default:
+ if (!candidateMrid.getModuleId().equals(dependencyMrid.getModuleId())) {
+ // it doesn't match org#module, skip to next
+ return null;
+ }
+ break;
}
Message.verbose("Workspace resolver found potential matching workspace module "
@@ -199,28 +203,25 @@ public abstract class AbstractWorkspaceResolver extends AbstractResolver {
if (allConfs.length == 0) {
newMd.addArtifact(ModuleDescriptor.DEFAULT_CONFIGURATION, af);
} else {
- for (int k = 0; k < allConfs.length; k++) {
- newMd.addConfiguration(allConfs[k]);
- newMd.addArtifact(allConfs[k].getName(), af);
+ for (Configuration conf : allConfs) {
+ newMd.addConfiguration(conf);
+ newMd.addArtifact(conf.getName(), af);
}
}
}
- DependencyDescriptor[] dependencies = md.getDependencies();
- for (int k = 0; k < dependencies.length; k++) {
- newMd.addDependency(dependencies[k]);
+ for (DependencyDescriptor dependency : md.getDependencies()) {
+ newMd.addDependency(dependency);
}
- ExcludeRule[] allExcludeRules = md.getAllExcludeRules();
- for (int k = 0; k < allExcludeRules.length; k++) {
- newMd.addExcludeRule(allExcludeRules[k]);
+ for (ExcludeRule excludeRule : md.getAllExcludeRules()) {
+ newMd.addExcludeRule(excludeRule);
}
newMd.getExtraInfos().addAll(md.getExtraInfos());
- License[] licenses = md.getLicenses();
- for (int k = 0; k < licenses.length; k++) {
- newMd.addLicense(licenses[k]);
+ for (License license : md.getLicenses()) {
+ newMd.addLicense(license);
}
return newMd;
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java b/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
index ae0ce47..b45db09 100644
--- a/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/BasicResolver.java
@@ -140,9 +140,9 @@ public abstract class BasicResolver extends AbstractResolver {
*/
private boolean envDependent = true;
- private List<String> ivyattempts = new ArrayList<String>();
+ private List<String> ivyattempts = new ArrayList<>();
- private Map<Artifact, List<String>> artattempts = new HashMap<Artifact, List<String>>();
+ private Map<Artifact, List<String>> artattempts = new HashMap<>();
private boolean checkconsistency = true;
@@ -471,7 +471,7 @@ public abstract class BasicResolver extends AbstractResolver {
private ModuleRevisionId getRevision(ResolvedResource ivyRef, ModuleRevisionId askedMrid,
ModuleDescriptor md) {
- Map<String, String> allAttributes = new HashMap<String, String>();
+ Map<String, String> allAttributes = new HashMap<>();
allAttributes.putAll(md.getQualifiedExtraAttributes());
allAttributes.putAll(askedMrid.getQualifiedExtraAttributes());
@@ -656,8 +656,8 @@ public abstract class BasicResolver extends AbstractResolver {
ResolvedResource found = null;
List<ArtifactInfo> sorted = getLatestStrategy().sort(rress);
- List<String> rejected = new ArrayList<String>();
- List<ModuleRevisionId> foundBlacklisted = new ArrayList<ModuleRevisionId>();
+ List<String> rejected = new ArrayList<>();
+ List<ModuleRevisionId> foundBlacklisted = new ArrayList<>();
IvyContext context = IvyContext.getContext();
for (ListIterator<ArtifactInfo> iter = sorted.listIterator(sorted.size()); iter
@@ -667,7 +667,7 @@ public abstract class BasicResolver extends AbstractResolver {
// even though we don't even know if the resource actually exist.
// But checking for existence is most of the time more costly than checking
// name, blacklisting and first level version matching
- if (filterNames(new ArrayList<String>(Collections.singleton(rres.getRevision())))
+ if (filterNames(new ArrayList<>(Collections.singleton(rres.getRevision())))
.isEmpty()) {
Message.debug("\t" + name + ": filtered by name: " + rres);
continue;
@@ -772,7 +772,7 @@ public abstract class BasicResolver extends AbstractResolver {
protected void logArtifactAttempt(Artifact art, String attempt) {
List<String> attempts = artattempts.get(art);
if (attempts == null) {
- attempts = new ArrayList<String>();
+ attempts = new ArrayList<>();
artattempts.put(art, attempts);
}
attempts.add(attempt);
@@ -826,9 +826,9 @@ public abstract class BasicResolver extends AbstractResolver {
clearArtifactAttempts();
DownloadReport dr = new DownloadReport();
- for (int i = 0; i < artifacts.length; i++) {
- ArtifactDownloadReport adr = cacheManager.download(artifacts[i],
- artifactResourceResolver, downloader, getCacheDownloadOptions(options));
+ for (Artifact artifact : artifacts) {
+ ArtifactDownloadReport adr = cacheManager.download(artifact, artifactResourceResolver,
+ downloader, getCacheDownloadOptions(options));
if (DownloadStatus.FAILED == adr.getDownloadStatus()) {
if (!ArtifactDownloadReport.MISSING_ARTIFACT.equals(adr.getDownloadDetails())) {
Message.warn("\t" + adr);
@@ -929,7 +929,7 @@ public abstract class BasicResolver extends AbstractResolver {
@Override
public ModuleEntry[] listModules(OrganisationEntry org) {
- Map<String, String> tokenValues = new HashMap<String, String>();
+ Map<String, String> tokenValues = new HashMap<>();
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org.getOrganisation());
Collection<String> names = findNames(tokenValues, IvyPatternHelper.MODULE_KEY);
ModuleEntry[] ret = new ModuleEntry[names.size()];
@@ -942,7 +942,7 @@ public abstract class BasicResolver extends AbstractResolver {
@Override
public RevisionEntry[] listRevisions(ModuleEntry mod) {
- Map<String, String> tokenValues = new HashMap<String, String>();
+ Map<String, String> tokenValues = new HashMap<>();
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, mod.getOrganisation());
tokenValues.put(IvyPatternHelper.MODULE_KEY, mod.getModule());
Collection<String> names = findNames(tokenValues, IvyPatternHelper.REVISION_KEY);
@@ -1098,7 +1098,7 @@ public abstract class BasicResolver extends AbstractResolver {
} else {
throw new IllegalArgumentException("unknown descriptor rule '" + descriptorRule
+ "'. Allowed rules are: "
- + Arrays.asList(new String[] {DESCRIPTOR_REQUIRED, DESCRIPTOR_OPTIONAL}));
+ + Arrays.asList(DESCRIPTOR_REQUIRED, DESCRIPTOR_OPTIONAL));
}
}
@@ -1109,7 +1109,7 @@ public abstract class BasicResolver extends AbstractResolver {
}
// csDef is a comma separated list of checksum algorithms to use with this resolver
// we parse and return it as a String[]
- List<String> algos = new ArrayList<String>();
+ List<String> algos = new ArrayList<>();
for (String checksum : csDef.split(",")) {
String cs = checksum.trim();
if (!"".equals(cs) && !"none".equals(cs)) {
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java b/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
index a08226d..337afb9 100644
--- a/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/CacheResolver.java
@@ -107,13 +107,13 @@ public class CacheResolver extends FileSystemResolver {
ensureConfigured();
clearArtifactAttempts();
DownloadReport dr = new DownloadReport();
- for (int i = 0; i < artifacts.length; i++) {
- final ArtifactDownloadReport adr = new ArtifactDownloadReport(artifacts[i]);
+ for (Artifact artifact : artifacts) {
+ final ArtifactDownloadReport adr = new ArtifactDownloadReport(artifact);
dr.addArtifactReport(adr);
- ResolvedResource artifactRef = getArtifactRef(artifacts[i], null);
+ ResolvedResource artifactRef = getArtifactRef(artifact, null);
if (artifactRef != null) {
- Message.verbose("\t[NOT REQUIRED] " + artifacts[i]);
- ArtifactOrigin origin = new ArtifactOrigin(artifacts[i], true, artifactRef
+ Message.verbose("\t[NOT REQUIRED] " + artifact);
+ ArtifactOrigin origin = new ArtifactOrigin(artifact, true, artifactRef
.getResource().getName());
File archiveFile = ((FileResource) artifactRef.getResource()).getFile();
adr.setDownloadStatus(DownloadStatus.NO);
@@ -173,14 +173,14 @@ public class CacheResolver extends FileSystemResolver {
setIvyPatterns(new ArrayList<String>());
setArtifactPatterns(new ArrayList<String>());
RepositoryCacheManager[] caches = getSettings().getRepositoryCacheManagers();
- for (int i = 0; i < caches.length; i++) {
- if (caches[i] instanceof DefaultRepositoryCacheManager) {
- DefaultRepositoryCacheManager c = (DefaultRepositoryCacheManager) caches[i];
+ for (RepositoryCacheManager cache : caches) {
+ if (cache instanceof DefaultRepositoryCacheManager) {
+ DefaultRepositoryCacheManager c = (DefaultRepositoryCacheManager) cache;
addIvyPattern(c.getBasedir().getAbsolutePath() + "/" + c.getIvyPattern());
addArtifactPattern(c.getBasedir().getAbsolutePath() + "/"
+ c.getArtifactPattern());
} else {
- Message.verbose(caches[i]
+ Message.verbose(cache
+ ": cache implementation is not a DefaultRepositoryCacheManager:"
+ " unable to configure cache resolver with it");
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java b/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
index 8cf574c..18ce352 100644
--- a/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/ChainResolver.java
@@ -24,7 +24,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.HashSet;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -69,7 +68,7 @@ public class ChainResolver extends AbstractResolver {
private boolean returnFirst = false;
- private List<DependencyResolver> chain = new ArrayList<DependencyResolver>();
+ private List<DependencyResolver> chain = new ArrayList<>();
private boolean dual;
@@ -81,7 +80,7 @@ public class ChainResolver extends AbstractResolver {
throws ParseException {
data = new ResolveData(data, doValidate(data));
- List<Exception> errors = new ArrayList<Exception>();
+ List<Exception> errors = new ArrayList<>();
ResolvedModuleRevision resolved = data.getCurrentResolvedModuleRevision();
ResolvedModuleRevision mr = resolved;
@@ -125,7 +124,7 @@ public class ChainResolver extends AbstractResolver {
throw new RuntimeException(ex.toString(), ex);
}
} else {
- StringBuffer err = new StringBuffer();
+ StringBuilder err = new StringBuilder();
for (Exception ex : errors) {
err.append("\t").append(StringUtils.getErrorMessage(ex)).append("\n");
}
@@ -183,10 +182,10 @@ public class ChainResolver extends AbstractResolver {
@Override
public Map<String, String>[] listTokenValues(String[] tokens, Map<String, Object> criteria) {
- Set<Map<String, String>> result = new HashSet<Map<String, String>>();
+ Set<Map<String, String>> result = new HashSet<>();
for (DependencyResolver resolver : chain) {
Map<String, String>[] temp = resolver.listTokenValues(tokens,
- new HashMap<String, Object>(criteria));
+ new HashMap<>(criteria));
result.addAll(Arrays.asList(temp));
}
@@ -208,18 +207,18 @@ public class ChainResolver extends AbstractResolver {
}
public DownloadReport download(Artifact[] artifacts, DownloadOptions options) {
- List<Artifact> artifactsToDownload = new ArrayList<Artifact>(Arrays.asList(artifacts));
+ List<Artifact> artifactsToDownload = new ArrayList<>(Arrays.asList(artifacts));
DownloadReport report = new DownloadReport();
- for (Iterator<DependencyResolver> iter = chain.iterator(); iter.hasNext()
- && !artifactsToDownload.isEmpty();) {
- DependencyResolver resolver = iter.next();
+ for (DependencyResolver resolver : chain) {
+ if (artifactsToDownload.isEmpty()) {
+ break;
+ }
DownloadReport r = resolver.download(
artifactsToDownload.toArray(new Artifact[artifactsToDownload.size()]), options);
- ArtifactDownloadReport[] adr = r.getArtifactsReports();
- for (int i = 0; i < adr.length; i++) {
- if (adr[i].getDownloadStatus() != DownloadStatus.FAILED) {
- artifactsToDownload.remove(adr[i].getArtifact());
- report.addArtifactReport(adr[i]);
+ for (ArtifactDownloadReport adr : r.getArtifactsReports()) {
+ if (adr.getDownloadStatus() != DownloadStatus.FAILED) {
+ artifactsToDownload.remove(adr.getArtifact());
+ report.addArtifactReport(adr);
}
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/DualResolver.java b/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
index 376a862..4f816ba 100644
--- a/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/DualResolver.java
@@ -218,7 +218,7 @@ public class DualResolver extends AbstractResolver {
} else {
throw new IllegalArgumentException("unknown descriptor rule '" + descriptorRule
+ "'. Allowed rules are: "
- + Arrays.asList(new String[] {DESCRIPTOR_REQUIRED, DESCRIPTOR_OPTIONAL}));
+ + Arrays.asList(DESCRIPTOR_REQUIRED, DESCRIPTOR_OPTIONAL));
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java b/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
index 8f2aad8..f217693 100644
--- a/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/FileSystemResolver.java
@@ -67,7 +67,7 @@ public class FileSystemResolver extends RepositoryResolver {
* Map between actual patterns and patterns used during the transaction to put files in a
* temporary directory
*/
- private Map<String, String> fullTransactionPatterns = new HashMap<String, String>();
+ private Map<String, String> fullTransactionPatterns = new HashMap<>();
/**
* Location where files are published during the transaction
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java b/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
index 7dc37b4..184a28a 100644
--- a/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/IBiblioResolver.java
@@ -198,9 +198,7 @@ public class IBiblioResolver extends URLResolver {
}
} catch (IOException e) {
Message.verbose("impossible to access maven metadata file, ignored", e);
- } catch (SAXException e) {
- Message.verbose("impossible to parse maven metadata file, ignored", e);
- } catch (ParserConfigurationException e) {
+ } catch (SAXException | ParserConfigurationException e) {
Message.verbose("impossible to parse maven metadata file, ignored", e);
} finally {
if (metadataStream != null) {
@@ -356,7 +354,8 @@ public class IBiblioResolver extends URLResolver {
String metadataLocation = pattern.substring(0,
pattern.lastIndexOf(partiallyResolvedM2PerModulePattern))
+ "maven-metadata.xml";
- List<?> revs = listRevisionsWithMavenMetadata(getRepository(), metadataLocation);
+ List<String> revs = listRevisionsWithMavenMetadata(getRepository(),
+ metadataLocation);
if (revs != null) {
return revs.toArray(new String[revs.size()]);
}
@@ -402,7 +401,7 @@ public class IBiblioResolver extends URLResolver {
.getAttributes());
if (revs != null) {
Message.debug("\tfound revs: " + revs);
- List<ResolvedResource> rres = new ArrayList<ResolvedResource>();
+ List<ResolvedResource> rres = new ArrayList<>();
for (String rev : revs) {
ModuleRevisionId historicalMrid = ModuleRevisionId.newInstance(mrid, rev);
@@ -456,7 +455,7 @@ public class IBiblioResolver extends URLResolver {
Resource metadata = repository.getResource(metadataLocation);
if (metadata.exists()) {
Message.verbose("\tlisting revisions from maven-metadata: " + metadata);
- final List<String> metadataRevs = new ArrayList<String>();
+ final List<String> metadataRevs = new ArrayList<>();
metadataStream = metadata.openStream();
XMLHelper.parse(metadataStream, null, new ContextualSAXHandler() {
@Override
@@ -474,9 +473,7 @@ public class IBiblioResolver extends URLResolver {
}
} catch (IOException e) {
Message.verbose("impossible to access maven metadata file, ignored", e);
- } catch (SAXException e) {
- Message.verbose("impossible to parse maven metadata file, ignored", e);
- } catch (ParserConfigurationException e) {
+ } catch (SAXException | ParserConfigurationException e) {
Message.verbose("impossible to parse maven metadata file, ignored", e);
} finally {
if (metadataStream != null) {
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java b/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
index 53b2d01..51a7d7f 100644
--- a/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/IvyRepResolver.java
@@ -224,7 +224,7 @@ public class IvyRepResolver extends URLResolver {
ensureIvyConfigured(getSettings());
try {
URL content = new URL(ivyroot + "content.xml");
- final List<OrganisationEntry> ret = new ArrayList<OrganisationEntry>();
+ final List<OrganisationEntry> ret = new ArrayList<>();
XMLHelper.parse(content, null, new DefaultHandler() {
@Override
public void startElement(String uri, String localName, String qName,
@@ -251,7 +251,7 @@ public class IvyRepResolver extends URLResolver {
@Override
public ModuleEntry[] listModules(OrganisationEntry org) {
ensureIvyConfigured(getSettings());
- Map<String, String> tokenValues = new HashMap<String, String>();
+ Map<String, String> tokenValues = new HashMap<>();
tokenValues.put(IvyPatternHelper.ORGANISATION_KEY, org.getOrganisation());
Collection<String> names = findIvyNames(tokenValues, IvyPatternHelper.MODULE_KEY);
ModuleEntry[] ret = new ModuleEntry[names.size()];
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java b/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java
index 2d17308..eeb3339 100644
--- a/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/MirroredURLResolver.java
@@ -57,7 +57,7 @@ public class MirroredURLResolver extends RepositoryResolver {
throw new IllegalStateException("The mirror list could not be read from "
+ mirrorListUrl + " (" + e.getMessage() + ")");
}
- List<Repository> repositories = new ArrayList<Repository>();
+ List<Repository> repositories = new ArrayList<>();
for (String baseUrl : mirrorBaseUrls) {
URL url = null;
try {
@@ -87,17 +87,14 @@ public class MirroredURLResolver extends RepositoryResolver {
}
private List<String> readMirrorList(File mirrorListFile) throws IOException {
- BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(
- mirrorListFile)));
- List<String> list = new ArrayList<String>();
- try {
+ List<String> list = new ArrayList<>();
+ try (BufferedReader in = new BufferedReader(new InputStreamReader(new FileInputStream(
+ mirrorListFile)))) {
String line = in.readLine();
while (line != null) {
list.add(line);
line = in.readLine();
}
- } finally {
- in.close();
}
return list;
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java b/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
index 435a27a..ec01e5f 100644
--- a/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/RepositoryResolver.java
@@ -98,7 +98,9 @@ public class RepositoryResolver extends AbstractPatternsBasedResolver {
boolean reachable = res.exists();
if (reachable) {
String revision;
- if (pattern.indexOf(IvyPatternHelper.REVISION_KEY) == -1) {
+ if (pattern.contains(IvyPatternHelper.REVISION_KEY)) {
+ revision = mrid.getRevision();
+ } else {
if ("ivy".equals(artifact.getType()) || "pom".equals(artifact.getType())) {
// we can't determine the revision from the pattern, get it
// from the moduledescriptor itself
@@ -116,8 +118,6 @@ public class RepositoryResolver extends AbstractPatternsBasedResolver {
} else {
revision = "working@" + name;
}
- } else {
- revision = mrid.getRevision();
}
return new ResolvedResource(res, revision);
} else if (versionMatcher.isDynamic(mrid)) {
@@ -130,10 +130,7 @@ public class RepositoryResolver extends AbstractPatternsBasedResolver {
} else {
return findDynamicResourceUsingPattern(rmdparser, mrid, pattern, artifact, date);
}
- } catch (IOException ex) {
- throw new RuntimeException(name + ": unable to get resource for " + mrid + ": res="
- + IvyPatternHelper.substitute(pattern, mrid, artifact) + ": " + ex, ex);
- } catch (ParseException ex) {
+ } catch (IOException | ParseException ex) {
throw new RuntimeException(name + ": unable to get resource for " + mrid + ": res="
+ IvyPatternHelper.substitute(pattern, mrid, artifact) + ": " + ex, ex);
}
@@ -228,15 +225,15 @@ public class RepositoryResolver extends AbstractPatternsBasedResolver {
throws IOException {
// verify the checksum algorithms before uploading artifacts!
String[] checksums = getChecksumAlgorithms();
- for (int i = 0; i < checksums.length; i++) {
- if (!ChecksumHelper.isKnownAlgorithm(checksums[i])) {
- throw new IllegalArgumentException("Unknown checksum algorithm: " + checksums[i]);
+ for (String checksum : checksums) {
+ if (!ChecksumHelper.isKnownAlgorithm(checksum)) {
+ throw new IllegalArgumentException("Unknown checksum algorithm: " + checksum);
}
}
repository.put(artifact, src, dest, overwrite);
- for (int i = 0; i < checksums.length; i++) {
- putChecksum(artifact, src, dest, overwrite, checksums[i]);
+ for (String checksum : checksums) {
+ putChecksum(artifact, src, dest, overwrite, checksum);
}
if (signerName != null) {
@@ -303,7 +300,7 @@ public class RepositoryResolver extends AbstractPatternsBasedResolver {
String[] values = ResolverHelper.listTokenValues(repository, partiallyResolvedPattern,
token);
if (values != null) {
- names.addAll(filterNames(new ArrayList<String>(Arrays.asList(values))));
+ names.addAll(filterNames(new ArrayList<>(Arrays.asList(values))));
}
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/VfsResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/VfsResolver.java b/src/java/org/apache/ivy/plugins/resolver/VfsResolver.java
index afae993..931b704 100644
--- a/src/java/org/apache/ivy/plugins/resolver/VfsResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/VfsResolver.java
@@ -50,7 +50,7 @@ public class VfsResolver extends RepositoryResolver {
if (m.matches()) {
final String password = m.group(PASSWORD_GROUP);
final int passwordposi = s.indexOf(password);
- StringBuffer stars = new StringBuffer(password);
+ StringBuilder stars = new StringBuilder(password);
for (int posi = 0; posi < password.length(); posi++) {
stars.setCharAt(posi, '*');
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java b/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java
index b88f0e5..f183e95 100644
--- a/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java
+++ b/src/java/org/apache/ivy/plugins/resolver/packager/PackagerCacheEntry.java
@@ -20,9 +20,7 @@ package org.apache.ivy.plugins.resolver.packager;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
-import java.util.Iterator;
import java.util.Map;
-import java.util.Map.Entry;
import org.apache.ivy.core.IvyPatternHelper;
import org.apache.ivy.core.module.descriptor.Artifact;
@@ -91,7 +89,7 @@ public class PackagerCacheEntry {
* @throws IOException
* if this entry has already been built
*/
- public synchronized void build(Resource packagerResource, Map properties) throws IOException {
+ public synchronized void build(Resource packagerResource, Map<String, String> properties) throws IOException {
// Sanity check
if (this.built) {
throw new IllegalStateException("build in directory `" + this.dir
@@ -157,9 +155,8 @@ public class PackagerCacheEntry {
project.setUserProperty("ivy.packager.restricted", "" + this.restricted);
project.setUserProperty("ivy.packager.quiet", String.valueOf(quiet));
if (properties != null) {
- for (Iterator it = properties.entrySet().iterator(); it.hasNext();) {
- Entry entry = (Entry) it.next();
- project.setUserProperty((String) entry.getKey(), (String) entry.getValue());
+ for (Map.Entry<String, String> entry : properties.entrySet()) {
+ project.setUserProperty(entry.getKey(), entry.getValue());
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/packager/PackagerResolver.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/packager/PackagerResolver.java b/src/java/org/apache/ivy/plugins/resolver/packager/PackagerResolver.java
index 26ed972..7142c0d 100644
--- a/src/java/org/apache/ivy/plugins/resolver/packager/PackagerResolver.java
+++ b/src/java/org/apache/ivy/plugins/resolver/packager/PackagerResolver.java
@@ -22,7 +22,6 @@ import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
@@ -50,7 +49,7 @@ public class PackagerResolver extends URLResolver {
private static final String PACKAGER_ARTIFACT_EXT = "xml";
- private final HashMap/* <ModuleRevisionId, PackagerCacheEntry> */packagerCache = new HashMap();
+ private final HashMap<ModuleRevisionId, PackagerCacheEntry> packagerCache = new HashMap<>();
private File buildRoot;
@@ -58,7 +57,7 @@ public class PackagerResolver extends URLResolver {
private String resourceURL;
- private Map/* <String,String> */properties = new LinkedHashMap();
+ private final Map<String, String> properties = new LinkedHashMap<>();
private boolean validate = true;
@@ -82,8 +81,7 @@ public class PackagerResolver extends URLResolver {
if (this.preserve) {
return;
}
- for (Iterator i = packagerCache.values().iterator(); i.hasNext();) {
- PackagerCacheEntry entry = (PackagerCacheEntry) i.next();
+ for (PackagerCacheEntry entry : packagerCache.values()) {
entry.cleanup();
}
packagerCache.clear();
@@ -143,7 +141,7 @@ public class PackagerResolver extends URLResolver {
* @param pattern String
*/
public void setPackagerPattern(String pattern) {
- ArrayList list = new ArrayList();
+ ArrayList<String> list = new ArrayList<>();
list.add(pattern);
setArtifactPatterns(list);
}
@@ -241,7 +239,7 @@ public class PackagerResolver extends URLResolver {
// Check the cache
ModuleRevisionId mr = artifact.getModuleRevisionId();
- PackagerCacheEntry entry = (PackagerCacheEntry) packagerCache.get(mr);
+ PackagerCacheEntry entry = packagerCache.get(mr);
// Ignore invalid entries
if (entry != null && !entry.isBuilt()) {
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/util/FileURLLister.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/util/FileURLLister.java b/src/java/org/apache/ivy/plugins/resolver/util/FileURLLister.java
index f5c680d..bab3476 100644
--- a/src/java/org/apache/ivy/plugins/resolver/util/FileURLLister.java
+++ b/src/java/org/apache/ivy/plugins/resolver/util/FileURLLister.java
@@ -52,10 +52,10 @@ public class FileURLLister implements URLLister {
File file = basedir == null ? new File(path) : new File(basedir, path);
if (file.exists() && file.isDirectory()) {
String[] files = file.list();
- List<URL> ret = new ArrayList<URL>(files.length);
+ List<URL> ret = new ArrayList<>(files.length);
URL context = url.getPath().endsWith("/") ? url : new URL(url.toExternalForm() + "/");
- for (int i = 0; i < files.length; i++) {
- ret.add(new URL(context, files[i]));
+ for (String fileName : files) {
+ ret.add(new URL(context, fileName));
}
return ret;
} else {
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java b/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java
index 2b7aec6..0f78e7f 100644
--- a/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java
+++ b/src/java/org/apache/ivy/plugins/resolver/util/ResolverHelper.java
@@ -63,7 +63,7 @@ public final class ResolverHelper {
String[] all = listAll(rep, root);
if (all != null) {
Message.debug("\t\tfound " + all.length + " urls");
- List<String> ret = new ArrayList<String>(all.length);
+ List<String> ret = new ArrayList<>(all.length);
int endNameIndex = pattern.indexOf(fileSep, slashIndex + 1);
String namePattern;
if (endNameIndex != -1) {
@@ -100,7 +100,7 @@ public final class ResolverHelper {
List<String> all = rep.list(parent);
if (all != null) {
Message.debug("\t\tfound " + all.size() + " resources");
- List<String> names = new ArrayList<String>(all.size());
+ List<String> names = new ArrayList<>(all.size());
for (String path : all) {
if (path.endsWith(fileSep)) {
path = path.substring(0, path.length() - 1);
@@ -135,17 +135,17 @@ public final class ResolverHelper {
IvyPatternHelper.REVISION_KEY);
if (revs != null) {
Message.debug("\tfound revs: " + Arrays.asList(revs));
- List<ResolvedResource> ret = new ArrayList<ResolvedResource>(revs.length);
- for (int i = 0; i < revs.length; i++) {
+ List<ResolvedResource> ret = new ArrayList<>(revs.length);
+ for (String rev : revs) {
String rres = IvyPatternHelper.substituteToken(partiallyResolvedPattern,
- IvyPatternHelper.REVISION_KEY, revs[i]);
+ IvyPatternHelper.REVISION_KEY, rev);
try {
Resource res = rep.getResource(rres);
if (res != null) {
// we do not test if the resource actually exist here, it would cause
// a lot of checks which are not always necessary depending on the usage
// which is done of the returned ResolvedResource array
- ret.add(new ResolvedResource(res, revs[i]));
+ ret.add(new ResolvedResource(res, rev));
}
} catch (IOException e) {
Message.warn("impossible to get resource from name listed by repository: "
@@ -156,7 +156,7 @@ public final class ResolverHelper {
Message.debug("\tfound resolved res: " + ret);
}
return ret.toArray(new ResolvedResource[ret.size()]);
- } else if (partiallyResolvedPattern.indexOf("[" + IvyPatternHelper.REVISION_KEY + "]") == -1) {
+ } else if (!partiallyResolvedPattern.contains("[" + IvyPatternHelper.REVISION_KEY + "]")) {
// the partially resolved pattern is completely resolved, check the resource
try {
Resource res = rep.getResource(partiallyResolvedPattern);
@@ -267,7 +267,7 @@ public final class ResolverHelper {
Message.debug("\tusing " + lister + " to list all in " + root);
List<URL> all = lister.listAll(new URL(root));
Message.debug("\t\tfound " + all.size() + " urls");
- List<String> ret = new ArrayList<String>(all.size());
+ List<String> ret = new ArrayList<>(all.size());
int endNameIndex = pattern.indexOf('/', slashIndex + 1);
String namePattern;
if (endNameIndex != -1) {
@@ -308,7 +308,7 @@ public final class ResolverHelper {
Message.debug("\tusing " + lister + " to list all in " + root);
List<URL> all = lister.listAll(root);
Message.debug("\t\tfound " + all.size() + " urls");
- List<String> names = new ArrayList<String>(all.size());
+ List<String> names = new ArrayList<>(all.size());
for (URL dir : all) {
String path = dir.getPath();
if (path.endsWith("/")) {
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java b/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
index c90608b..33b880b 100644
--- a/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
+++ b/src/java/org/apache/ivy/plugins/signer/bouncycastle/OpenPGPSignatureGenerator.java
@@ -120,9 +120,7 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator {
sGen.generate().encode(out);
} catch (PGPException e) {
- IOException ioexc = new IOException();
- ioexc.initCause(e);
- throw ioexc;
+ throw new IOException(e);
} finally {
if (out != null) {
try {
@@ -161,7 +159,7 @@ public class OpenPGPSignatureGenerator implements SignatureGenerator {
key = k;
}
if ((keyId != null)
- && (Long.valueOf(keyId, 16).longValue() == (k.getKeyID() & MASK))) {
+ && (Long.valueOf(keyId, 16) == (k.getKeyID() & MASK))) {
key = k;
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java b/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java
index e0f711f..5655305 100644
--- a/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java
+++ b/src/java/org/apache/ivy/plugins/version/AbstractVersionMatcher.java
@@ -63,7 +63,7 @@ public abstract class AbstractVersionMatcher implements VersionMatcher, IvySetti
* @return int
*/
public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
- Comparator staticComparator) {
+ Comparator<ModuleRevisionId> staticComparator) {
return 0;
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/version/ChainVersionMatcher.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/version/ChainVersionMatcher.java b/src/java/org/apache/ivy/plugins/version/ChainVersionMatcher.java
index e5e82b2..5ab5d71 100644
--- a/src/java/org/apache/ivy/plugins/version/ChainVersionMatcher.java
+++ b/src/java/org/apache/ivy/plugins/version/ChainVersionMatcher.java
@@ -39,7 +39,7 @@ public class ChainVersionMatcher extends AbstractVersionMatcher {
* The list of version matchers in the chain. This list will be queried in order, so the last
* matcher will be used only if no other matcher accept the revision before.
*/
- private List/* <VersionMatcher> */matchers = new LinkedList();
+ private final List<VersionMatcher> matchers = new LinkedList<>();
/**
* Unique Constructor.
@@ -71,8 +71,7 @@ public class ChainVersionMatcher extends AbstractVersionMatcher {
*/
public void setSettings(IvySettings settings) {
super.setSettings(settings);
- for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher) iter.next();
+ for (VersionMatcher matcher : matchers) {
if (matcher instanceof IvySettingsAware) {
((IvySettingsAware) matcher).setSettings(settings);
}
@@ -87,14 +86,13 @@ public class ChainVersionMatcher extends AbstractVersionMatcher {
*
* @return the list of matchers in the chain. Is never null.
*/
- public List getMatchers() {
+ public List<VersionMatcher> getMatchers() {
return Collections.unmodifiableList(matchers);
}
public boolean isDynamic(ModuleRevisionId askedMrid) {
Checks.checkNotNull(askedMrid, "askedMrid");
- for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher) iter.next();
+ for (VersionMatcher matcher : matchers) {
if (matcher.isDynamic(askedMrid)) {
return true;
}
@@ -103,12 +101,11 @@ public class ChainVersionMatcher extends AbstractVersionMatcher {
}
public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
- Comparator staticComparator) {
+ Comparator<ModuleRevisionId> staticComparator) {
Checks.checkNotNull(askedMrid, "askedMrid");
Checks.checkNotNull(foundMrid, "foundMrid");
Checks.checkNotNull(staticComparator, "staticComparator");
- for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher) iter.next();
+ for (VersionMatcher matcher : matchers) {
if (matcher.isDynamic(askedMrid)) {
return matcher.compare(askedMrid, foundMrid, staticComparator);
}
@@ -120,8 +117,8 @@ public class ChainVersionMatcher extends AbstractVersionMatcher {
public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) {
Checks.checkNotNull(askedMrid, "askedMrid");
Checks.checkNotNull(foundMrid, "foundMrid");
- for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher) iter.next();
+ for (Iterator<VersionMatcher> iter = matchers.iterator(); iter.hasNext();) {
+ VersionMatcher matcher = iter.next();
if (!iter.hasNext() || matcher.isDynamic(askedMrid)) {
return matcher.accept(askedMrid, foundMrid);
}
@@ -132,8 +129,8 @@ public class ChainVersionMatcher extends AbstractVersionMatcher {
public boolean needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid) {
Checks.checkNotNull(askedMrid, "askedMrid");
Checks.checkNotNull(foundMrid, "foundMrid");
- for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher) iter.next();
+ for (Iterator<VersionMatcher> iter = matchers.iterator(); iter.hasNext();) {
+ VersionMatcher matcher = iter.next();
if (!iter.hasNext() || matcher.isDynamic(askedMrid)) {
return matcher.needModuleDescriptor(askedMrid, foundMrid);
}
@@ -144,8 +141,8 @@ public class ChainVersionMatcher extends AbstractVersionMatcher {
public boolean accept(ModuleRevisionId askedMrid, ModuleDescriptor foundMD) {
Checks.checkNotNull(askedMrid, "askedMrid");
Checks.checkNotNull(foundMD, "foundMD");
- for (Iterator iter = matchers.iterator(); iter.hasNext();) {
- VersionMatcher matcher = (VersionMatcher) iter.next();
+ for (Iterator<VersionMatcher> iter = matchers.iterator(); iter.hasNext();) {
+ VersionMatcher matcher = iter.next();
if (!iter.hasNext() || matcher.isDynamic(askedMrid)) {
return matcher.accept(askedMrid, foundMD);
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java b/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java
index dbfe79e..6740698 100644
--- a/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java
+++ b/src/java/org/apache/ivy/plugins/version/LatestVersionMatcher.java
@@ -68,7 +68,7 @@ public class LatestVersionMatcher extends AbstractVersionMatcher {
* @return int
*/
public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
- Comparator staticComparator) {
+ Comparator<ModuleRevisionId> staticComparator) {
return needModuleDescriptor(askedMrid, foundMrid) ? 0 : 1;
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/version/Match.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/version/Match.java b/src/java/org/apache/ivy/plugins/version/Match.java
index cb02d30..93f2838 100644
--- a/src/java/org/apache/ivy/plugins/version/Match.java
+++ b/src/java/org/apache/ivy/plugins/version/Match.java
@@ -83,7 +83,7 @@ public class Match {
return new NoMatchMatcher();
}
- Map variables = new HashMap();
+ Map<String, String> variables = new HashMap<>();
for (int i = 0; i < args.length; i++) {
variables.put(args[i], argValues[i]);
}
@@ -116,12 +116,12 @@ public class Match {
}
StringTokenizer tokenizer = new StringTokenizer(string, ", ");
- List tokens = new ArrayList();
+ List<String> tokens = new ArrayList<>();
while (tokenizer.hasMoreTokens()) {
tokens.add(tokenizer.nextToken());
}
- return (String[]) tokens.toArray(new String[tokens.size()]);
+ return tokens.toArray(new String[tokens.size()]);
}
private static class NoMatchMatcher implements Matcher {
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java b/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java
index a108847..74dbb7e 100644
--- a/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java
+++ b/src/java/org/apache/ivy/plugins/version/PatternVersionMatcher.java
@@ -19,7 +19,6 @@ package org.apache.ivy.plugins.version;
import java.util.ArrayList;
import java.util.HashMap;
-import java.util.Iterator;
import java.util.List;
import java.util.Map;
@@ -31,9 +30,10 @@ import org.apache.ivy.plugins.matcher.Matcher;
*/
public class PatternVersionMatcher extends AbstractVersionMatcher {
- private List matches = new ArrayList();
+ private final List<Match> matches = new ArrayList<>();
- private Map revisionMatches = new HashMap(); // revision -> list of Match instances
+ private final Map<String, List<Match>> revisionMatches = new HashMap<>();
+ // revision -> list of Match instances
private boolean init = false;
@@ -43,11 +43,10 @@ public class PatternVersionMatcher extends AbstractVersionMatcher {
private void init() {
if (!init) {
- for (Iterator it = matches.iterator(); it.hasNext();) {
- Match match = (Match) it.next();
- List revMatches = (List) revisionMatches.get(match.getRevision());
+ for (Match match : matches) {
+ List<Match> revMatches = revisionMatches.get(match.getRevision());
if (revMatches == null) {
- revMatches = new ArrayList();
+ revMatches = new ArrayList<>();
revisionMatches.put(match.getRevision(), revMatches);
}
revMatches.add(match);
@@ -69,14 +68,15 @@ public class PatternVersionMatcher extends AbstractVersionMatcher {
revision = revision.substring(0, bracketIndex);
}
- List revMatches = (List) revisionMatches.get(revision);
+ List<Match> revMatches = revisionMatches.get(revision);
if (revMatches != null) {
- Iterator it = revMatches.iterator();
- while (!accept && it.hasNext()) {
- Match match = (Match) it.next();
+ for (Match match : revMatches) {
Matcher matcher = match.getPatternMatcher(askedMrid);
accept = matcher.matches(foundMrid.getRevision());
+ if (accept) {
+ break;
+ }
}
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/version/SubVersionMatcher.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/version/SubVersionMatcher.java b/src/java/org/apache/ivy/plugins/version/SubVersionMatcher.java
index b8e04cb..ea287f6 100644
--- a/src/java/org/apache/ivy/plugins/version/SubVersionMatcher.java
+++ b/src/java/org/apache/ivy/plugins/version/SubVersionMatcher.java
@@ -36,7 +36,7 @@ public class SubVersionMatcher extends AbstractVersionMatcher {
}
public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
- Comparator staticComparator) {
+ Comparator<ModuleRevisionId> staticComparator) {
if (foundMrid.getRevision().startsWith(
askedMrid.getRevision().substring(0, askedMrid.getRevision().length() - 1))) {
return 1;
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/version/VersionMatcher.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/version/VersionMatcher.java b/src/java/org/apache/ivy/plugins/version/VersionMatcher.java
index 184b28e..36563c2 100644
--- a/src/java/org/apache/ivy/plugins/version/VersionMatcher.java
+++ b/src/java/org/apache/ivy/plugins/version/VersionMatcher.java
@@ -50,7 +50,7 @@ public interface VersionMatcher {
* the dependency module revision id as asked by a module
* @return true if this revision is considered as a dynamic one, false otherwise
*/
- public boolean isDynamic(ModuleRevisionId askedMrid);
+ boolean isDynamic(ModuleRevisionId askedMrid);
/**
* Indicates if this version matcher considers that the module revision found matches the asked
@@ -60,7 +60,7 @@ public interface VersionMatcher {
* @param foundMrid ModuleRevisionId
* @return boolean
*/
- public boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid);
+ boolean accept(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid);
/**
* Indicates if this VersionMatcher needs module descriptors to determine if a module revision
@@ -71,7 +71,7 @@ public interface VersionMatcher {
* @param foundMrid ModuleRevisionId
* @return boolean
*/
- public boolean needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid);
+ boolean needModuleDescriptor(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid);
/**
* Indicates if this version matcher considers that the module found matches the asked one. This
@@ -83,7 +83,7 @@ public interface VersionMatcher {
* @param foundMD ModuleDescriptor
* @return boolean
*/
- public boolean accept(ModuleRevisionId askedMrid, ModuleDescriptor foundMD);
+ boolean accept(ModuleRevisionId askedMrid, ModuleDescriptor foundMD);
/**
* Compares a dynamic revision (askedMrid) with a static one (foundMrid) to indicate which one
@@ -100,13 +100,13 @@ public interface VersionMatcher {
* @return 0 if it's not possible to know which one is greater, greater than 0 if askedMrid
* should be considered greater, lower than 0 if it can't be consider greater
*/
- public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
- Comparator staticComparator);
+ int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
+ Comparator<ModuleRevisionId> staticComparator);
/**
* Returns the version matcher name identifying this version matcher
*
* @return the version matcher name identifying this version matcher
*/
- public String getName();
+ String getName();
}
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/d9665bfc/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java b/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java
index b547f4c..6c7f9a5 100644
--- a/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java
+++ b/src/java/org/apache/ivy/plugins/version/VersionRangeMatcher.java
@@ -114,15 +114,15 @@ public class VersionRangeMatcher extends AbstractVersionMatcher {
}
}
- private final Comparator comparator = new Comparator() {
- public int compare(Object o1, Object o2) {
+ private final Comparator<ModuleRevisionId> comparator = new Comparator<ModuleRevisionId>() {
+ public int compare(ModuleRevisionId o1, ModuleRevisionId o2) {
if (o1.equals(o2)) {
return 0;
}
- ArtifactInfo art1 = new MRIDArtifactInfo((ModuleRevisionId) o1);
- ArtifactInfo art2 = new MRIDArtifactInfo((ModuleRevisionId) o2);
- ArtifactInfo art = getLatestStrategy()
- .findLatest(new ArtifactInfo[] {art1, art2}, null);
+ ArtifactInfo art1 = new MRIDArtifactInfo(o1);
+ ArtifactInfo art2 = new MRIDArtifactInfo(o2);
+ ArtifactInfo art = getLatestStrategy().findLatest(new ArtifactInfo[] {art1, art2},
+ null);
return art == art1 ? -1 : 1;
}
};
@@ -187,7 +187,7 @@ public class VersionRangeMatcher extends AbstractVersionMatcher {
}
public int compare(ModuleRevisionId askedMrid, ModuleRevisionId foundMrid,
- Comparator staticComparator) {
+ Comparator<ModuleRevisionId> staticComparator) {
String revision = askedMrid.getRevision();
Matcher m;
m = UPPER_INFINITE_RANGE.matcher(revision);