Skip to content
Snippets Groups Projects
Commit 598e8615 authored by Jonas Blatt's avatar Jonas Blatt :ant:
Browse files

BugFix Compare to of String boundary

parent 7242d996
No related branches found
No related tags found
No related merge requests found
......@@ -57,8 +57,13 @@ import org.apache.commons.lang3.Validate;
* StringBoundary#matchesNoneOfValues} returns true, which are not in the boundary. <br>
*
* <p>Only value "a": <br>
* {@code "a"} <br> Value "a" or value "b": <br> {@code "a","b"} <br> Not value "a" and not value
* "b": <br> {@code not("a","b")} <br> All values: <br> {@code (empty String)}
* {@code "a"} <br>
* Value "a" or value "b": <br>
* {@code "a","b"} <br>
* Not value "a" and not value "b": <br>
* {@code not("a","b")} <br>
* All values: <br>
* {@code (empty String)}
*/
public class StringBoundary extends AbstractBoundary<String> {
......@@ -105,7 +110,21 @@ public class StringBoundary extends AbstractBoundary<String> {
@Override
public int compareTo(Boundary o) {
return o.getText().compareTo(o.getText());
if (!(o instanceof StringBoundary)) {
return 0;
}
StringBoundary otherStringB = (StringBoundary) o;
if (matchesAny() || matchesNoneOfValues()) {
if (otherStringB.matchesAny() || otherStringB.matchesNoneOfValues()) {
return 0;
} else {
return -1;
}
}
if (otherStringB.matchesAny() || otherStringB.matchesNoneOfValues()) {
return 1;
}
return this.getValues()[0].compareTo(otherStringB.getValues()[0]);
}
/**
......@@ -178,6 +197,7 @@ public class StringBoundary extends AbstractBoundary<String> {
}
private void calcHashes() {
Arrays.sort(values);
valuesHashes = new int[values.length];
for (int i = 0; i < values.length; i++) {
values[i] = values[i].replace('"', '\0').trim();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment