You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@ant.apache.org by gi...@apache.org on 2018/03/15 18:35:26 UTC
ant-ivy git commit: Make logic more concise
Repository: ant-ivy
Updated Branches:
refs/heads/master 5a2af8daa -> 4a2608ac1
Make logic more concise
Project: http://git-wip-us.apache.org/repos/asf/ant-ivy/repo
Commit: http://git-wip-us.apache.org/repos/asf/ant-ivy/commit/4a2608ac
Tree: http://git-wip-us.apache.org/repos/asf/ant-ivy/tree/4a2608ac
Diff: http://git-wip-us.apache.org/repos/asf/ant-ivy/diff/4a2608ac
Branch: refs/heads/master
Commit: 4a2608ac10847927b241f93159e269fcb263ed25
Parents: 5a2af8d
Author: Gintas Grigelionis <gi...@apache.org>
Authored: Thu Mar 15 19:35:15 2018 +0100
Committer: Gintas Grigelionis <gi...@apache.org>
Committed: Thu Mar 15 19:35:15 2018 +0100
----------------------------------------------------------------------
.../parser/m2/MavenVersionRangeParser.java | 32 +++++---------------
1 file changed, 7 insertions(+), 25 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ant-ivy/blob/4a2608ac/src/java/org/apache/ivy/plugins/parser/m2/MavenVersionRangeParser.java
----------------------------------------------------------------------
diff --git a/src/java/org/apache/ivy/plugins/parser/m2/MavenVersionRangeParser.java b/src/java/org/apache/ivy/plugins/parser/m2/MavenVersionRangeParser.java
index 0f13745..f8ac980 100644
--- a/src/java/org/apache/ivy/plugins/parser/m2/MavenVersionRangeParser.java
+++ b/src/java/org/apache/ivy/plugins/parser/m2/MavenVersionRangeParser.java
@@ -24,7 +24,8 @@ import java.util.StringTokenizer;
/**
* Parser that understands Maven version ranges of the form {@code (,1.0]} and such.
- * More details about such ranges in Maven, can be found {@link https://cwiki.apache.org/confluence/display/MAVENOLD/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges here}
+ * More details about such ranges in Maven, can be found
+ * {@link https://cwiki.apache.org/confluence/display/MAVENOLD/Dependency+Mediation+and+Conflict+Resolution#DependencyMediationandConflictResolution-DependencyVersionRanges here}
*/
class MavenVersionRangeParser {
@@ -56,10 +57,7 @@ class MavenVersionRangeParser {
return false;
}
final Range parsedRange = parse(range);
- if (parsedRange == null) {
- return false;
- }
- return parsedRange.accepts(javaVersion);
+ return parsedRange != null && parsedRange.accepts(javaVersion);
}
/**
@@ -79,10 +77,7 @@ class MavenVersionRangeParser {
return false;
}
final Range parsedRange = parse(range);
- if (parsedRange == null) {
- return false;
- }
- return parsedRange.accepts(valToCompare);
+ return parsedRange != null && parsedRange.accepts(valToCompare);
}
@@ -175,22 +170,9 @@ class MavenVersionRangeParser {
@Override
public boolean accepts(final DeweyDecimal value) {
- if (value == null) {
- return false;
- }
- final boolean withinLowerBound;
- if (this.lowerBound == null) {
- withinLowerBound = true;
- } else {
- withinLowerBound = this.lowerInclusive ? value.isGreaterThanOrEqual(lowerBound) : value.isGreaterThan(lowerBound);
- }
- final boolean withinUpperBound;
- if (this.upperBound == null) {
- withinUpperBound = true;
- } else {
- withinUpperBound = this.upperInclusive ? value.isLessThanOrEqual(upperBound) : value.isLessThan(upperBound);
- }
- return withinLowerBound && withinUpperBound;
+ return value != null
+ && (this.lowerBound == null || (this.lowerInclusive ? value.isGreaterThanOrEqual(lowerBound) : value.isGreaterThan(lowerBound)))
+ && (this.upperBound == null || (this.upperInclusive ? value.isLessThanOrEqual(upperBound) : value.isLessThan(upperBound)));
}
}