changed to reflect the function's acceptance of either simple string … (#3294)

* changed to reflect the function's acceptance of either simple string or regex

* cast p into a Pattern

* cast p into a Pattern

* Changed test to reflect the new output from function.
This commit is contained in:
rubyAnne 2020-11-01 02:52:36 -05:00 committed by GitHub
parent 77f26c1218
commit 352127558a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -55,9 +55,7 @@ public class Find implements Function {
}
if (s != null && p != null && p instanceof Pattern) {
Pattern pattern = (p instanceof String) ? Pattern.compile((String) p) : (Pattern) p;
Pattern pattern = (Pattern) p;
Matcher matcher = pattern.matcher(s.toString());
while (matcher.find()) {
@ -72,7 +70,7 @@ public class Find implements Function {
@Override
public String getDescription() {
return "Returns all the occurances of match given regular expression";
return "Returns all the occurrences of match given regular expression or simple string";
}
@Override

View File

@ -75,7 +75,7 @@ public class FindTests extends RefineTest {
@Test
public void serializeFind() {
String json = "{\"description\":\"Returns all the occurances of match given regular expression\",\"params\":\"string or regexp\",\"returns\":\"array of strings\"}";
String json = "{\"description\":\"Returns all the occurrences of match given regular expression or simple string\",\"params\":\"string or regexp\",\"returns\":\"array of strings\"}";
TestUtils.isSerializedTo(new Find(), json);
}
}