This repository has been archived by the owner on Jul 6, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 48
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #137 from pontusmelke/explain-rule-planner
EXPLAIN and rule planner
- Loading branch information
Showing
4 changed files
with
130 additions
and
13 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
cypher-shell/src/integration-test/java/org/neo4j/shell/Version.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.neo4j.shell; | ||
|
||
import static java.lang.String.format; | ||
|
||
@SuppressWarnings("WeakerAccess") | ||
public class Version implements Comparable<Version> { | ||
private final int major; | ||
private final int minor; | ||
private final int patch; | ||
|
||
Version(int major, int minor, int patch) { | ||
this.major = major; | ||
this.minor = minor; | ||
this.patch = patch; | ||
} | ||
|
||
public int major() { | ||
return major; | ||
} | ||
|
||
public int minor() { | ||
return minor; | ||
} | ||
|
||
public int patch() { | ||
return patch; | ||
} | ||
|
||
@Override | ||
public int compareTo(Version o) { | ||
int comp = Integer.compare(major, o.major); | ||
if (comp == 0) { | ||
comp = Integer.compare(minor, o.minor); | ||
if (comp == 0) { | ||
comp = Integer.compare(patch, o.patch); | ||
} | ||
} | ||
return comp; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
return format("%d.%d.%d", major, minor, patch); | ||
} | ||
} |
47 changes: 47 additions & 0 deletions
47
cypher-shell/src/integration-test/java/org/neo4j/shell/Versions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package org.neo4j.shell; | ||
|
||
import static java.lang.Integer.parseInt; | ||
import static java.lang.String.format; | ||
|
||
@SuppressWarnings({"WeakerAccess", "unused"}) | ||
public final class Versions { | ||
|
||
private Versions() { | ||
throw new UnsupportedOperationException("Don't instantiate"); | ||
} | ||
|
||
public static int majorVersion(String version) { | ||
return version(version).major(); | ||
} | ||
|
||
public static int minorVersion(String version) { | ||
return version(version).minor(); | ||
} | ||
|
||
public static int patch(String version) { | ||
return version(version).patch(); | ||
} | ||
|
||
public static Version version(String version) { | ||
if (version == null) { | ||
throw new AssertionError("null is not a valid version string"); | ||
} | ||
//remove -alpha, and -beta etc | ||
int offset = version.indexOf("-"); | ||
if (offset > 0) { | ||
version = version.substring(0, offset); | ||
} | ||
String[] split = version.split("\\."); | ||
switch (split.length) { | ||
case 1: | ||
return new Version(parseInt(split[0]), 0, 0); | ||
case 2: | ||
return new Version(parseInt(split[0]), parseInt(split[1]), 0); | ||
case 3: | ||
return new Version(parseInt(split[0]), parseInt(split[1]), parseInt(split[2])); | ||
default: | ||
throw new AssertionError( | ||
format("%s is not a proper version string, it should be of the form X.Y.Z ", version)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters