Skip to content

Instantly share code, notes, and snippets.

@chriswk
Created December 15, 2021 16:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chriswk/bac1f1b79267c2f5c40b0769455b08d9 to your computer and use it in GitHub Desktop.
Save chriswk/bac1f1b79267c2f5c40b0769455b08d9 to your computer and use it in GitHub Desktop.
public class CustomVersionRangeStrategy implements Strategy {
@Override
public String getName() {
return "CustomVersionStrategy";
}
@Override
public boolean isEnabled(Map<String, String> parameters) {
return false;
}
@Override
public boolean isEnabled(Map<String, String> parameters, UnleashContext unleashContext) {
Version minVersion = Version.of(parameters.get("minVersion"));
Version maxVersion = Version.of(parameters.get("maxVersion"));
Version clientVersion = Version.of(unleashContext.getProperties().get("version"));
return clientVersion.lessThanOrEqual(maxVersion) && clientVersion.greaterThanOrEqual(minVersion)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment