-
Notifications
You must be signed in to change notification settings - Fork 19
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 #504 from splitio/Feature/Semver
Merge semver to dev
- Loading branch information
Showing
37 changed files
with
1,506 additions
and
26 deletions.
There are no files selected for viewing
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
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,11 @@ | ||
package io.split; | ||
|
||
public final class Spec { | ||
|
||
private Spec() { | ||
// restrict instantiation | ||
} | ||
|
||
public static final String SPEC_VERSION = "1.1"; | ||
} | ||
|
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
11 changes: 11 additions & 0 deletions
11
client/src/main/java/io/split/client/dtos/BetweenStringMatcherData.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,11 @@ | ||
package io.split.client.dtos; | ||
|
||
/** | ||
* Metadata to support the between matcher. | ||
* | ||
* @author adil | ||
*/ | ||
public class BetweenStringMatcherData { | ||
public String start; | ||
public String end; | ||
} |
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
7 changes: 7 additions & 0 deletions
7
client/src/main/java/io/split/client/exceptions/SemverParseException.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,7 @@ | ||
package io.split.client.exceptions; | ||
|
||
public class SemverParseException extends Exception { | ||
public SemverParseException(String message) { | ||
super(message); | ||
} | ||
} |
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
58 changes: 58 additions & 0 deletions
58
client/src/main/java/io/split/engine/matchers/BetweenSemverMatcher.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,58 @@ | ||
package io.split.engine.matchers; | ||
|
||
import io.split.engine.evaluator.EvaluationContext; | ||
|
||
import java.util.Map; | ||
|
||
public class BetweenSemverMatcher implements Matcher { | ||
|
||
private final Semver _semverStart; | ||
private final Semver _semverEnd; | ||
|
||
public BetweenSemverMatcher(String semverStart, String semverEnd) { | ||
_semverStart = Semver.build(semverStart); | ||
_semverEnd = Semver.build(semverEnd); | ||
} | ||
|
||
@Override | ||
public boolean match(Object matchValue, String bucketingKey, Map<String, Object> attributes, EvaluationContext evaluationContext) { | ||
if (!(matchValue instanceof String) || _semverStart == null || _semverEnd == null) { | ||
return false; | ||
} | ||
Semver matchSemver = Semver.build(matchValue.toString()); | ||
if (matchSemver == null) { | ||
return false; | ||
} | ||
|
||
return matchSemver.compare(_semverStart) >= 0 && matchSemver.compare(_semverEnd) <= 0; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder bldr = new StringBuilder(); | ||
bldr.append("between semver "); | ||
bldr.append(_semverStart.version()); | ||
bldr.append(" and "); | ||
bldr.append(_semverEnd.version()); | ||
return bldr.toString(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = 17; | ||
result = 31 * result + _semverStart.hashCode() + _semverEnd.hashCode(); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) return false; | ||
if (this == obj) return true; | ||
if (!(obj instanceof BetweenSemverMatcher)) return false; | ||
|
||
BetweenSemverMatcher other = (BetweenSemverMatcher) obj; | ||
|
||
return _semverStart == other._semverStart && _semverEnd == other._semverEnd; | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
client/src/main/java/io/split/engine/matchers/EqualToSemverMatcher.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,54 @@ | ||
package io.split.engine.matchers; | ||
|
||
import io.split.engine.evaluator.EvaluationContext; | ||
|
||
import java.util.Map; | ||
|
||
public class EqualToSemverMatcher implements Matcher { | ||
|
||
private final Semver _semVer; | ||
|
||
public EqualToSemverMatcher(String semVer) { | ||
_semVer = Semver.build(semVer); | ||
} | ||
|
||
@Override | ||
public boolean match(Object matchValue, String bucketingKey, Map<String, Object> attributes, EvaluationContext evaluationContext) { | ||
if (!(matchValue instanceof String) || _semVer == null) { | ||
return false; | ||
} | ||
Semver matchSemver = Semver.build(matchValue.toString()); | ||
if (matchSemver == null) { | ||
return false; | ||
} | ||
|
||
return matchSemver.version().equals(_semVer.version()); | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder bldr = new StringBuilder(); | ||
bldr.append("== semver "); | ||
bldr.append(_semVer.version()); | ||
return bldr.toString(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = 17; | ||
result = 31 * result + _semVer.hashCode(); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) return false; | ||
if (this == obj) return true; | ||
if (!(obj instanceof EqualToSemverMatcher)) return false; | ||
|
||
EqualToSemverMatcher other = (EqualToSemverMatcher) obj; | ||
|
||
return _semVer == other._semVer; | ||
} | ||
|
||
} |
54 changes: 54 additions & 0 deletions
54
client/src/main/java/io/split/engine/matchers/GreaterThanOrEqualToSemverMatcher.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,54 @@ | ||
package io.split.engine.matchers; | ||
|
||
import io.split.engine.evaluator.EvaluationContext; | ||
|
||
import java.util.Map; | ||
|
||
public class GreaterThanOrEqualToSemverMatcher implements Matcher { | ||
|
||
private final Semver _semVer; | ||
|
||
public GreaterThanOrEqualToSemverMatcher(String semVer) { | ||
_semVer = Semver.build(semVer); | ||
} | ||
|
||
@Override | ||
public boolean match(Object matchValue, String bucketingKey, Map<String, Object> attributes, EvaluationContext evaluationContext) { | ||
if (!(matchValue instanceof String)|| _semVer == null) { | ||
return false; | ||
} | ||
Semver matchSemver = Semver.build(matchValue.toString()); | ||
if (matchSemver == null) { | ||
return false; | ||
} | ||
|
||
return matchSemver.compare(_semVer) >= 0; | ||
} | ||
|
||
@Override | ||
public String toString() { | ||
StringBuilder bldr = new StringBuilder(); | ||
bldr.append(">= semver "); | ||
bldr.append(_semVer.version()); | ||
return bldr.toString(); | ||
} | ||
|
||
@Override | ||
public int hashCode() { | ||
int result = 17; | ||
result = 31 * result + _semVer.hashCode(); | ||
return result; | ||
} | ||
|
||
@Override | ||
public boolean equals(Object obj) { | ||
if (obj == null) return false; | ||
if (this == obj) return true; | ||
if (!(obj instanceof GreaterThanOrEqualToSemverMatcher)) return false; | ||
|
||
GreaterThanOrEqualToSemverMatcher other = (GreaterThanOrEqualToSemverMatcher) obj; | ||
|
||
return _semVer == other._semVer; | ||
} | ||
|
||
} |
Oops, something went wrong.