Skip to content

Commit

Permalink
Add InstanceOfPatternMatch recipe to java-version-17.yml (#179)
Browse files Browse the repository at this point in the history
* Add `InstanceOfPatternMatch` recipe to `java-version-17.yml`

Related: openrewrite/rewrite#2690

* Move InstanceOfPatternMatch under UpgradeToJava17

* Add test for `InstanceOfPatternMatch` recipe

---------

Co-authored-by: Tim te Beek <tim@moderne.io>
  • Loading branch information
knutwannheden and timtebeek authored Jan 31, 2023
1 parent 8c7d4ee commit 316f660
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/main/resources/META-INF/rewrite/java-version-17.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ recipeList:
- org.openrewrite.java.migrate.lang.StringFormatted
- org.openrewrite.java.migrate.lombok.UpdateLombokToJava17
- org.openrewrite.github.SetupJavaUpgradeJavaVersion
- org.openrewrite.java.InstanceOfPatternMatch
---
type: specs.openrewrite.org/v1beta/recipe
name: org.openrewrite.java.migrate.JavaVersion17
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,11 @@ public void test() {
// This is a comment
Set<String> stringSet = Collections.singleton("aaa");
List<String> stringList = Collections.singletonList("bbb");
Map<String, String> stringMap = Collections.singletonMap("a-key", "a-value");
Map<String, Object> stringMap = Collections.singletonMap("a-key", "a-value");
Object value = stringMap.get("a-key");
if (value instanceof String) {
System.out.println(((String) value).length());
}
}
}
""",
Expand All @@ -110,7 +114,11 @@ public void test() {
// This is a comment
Set<String> stringSet = Set.of("aaa");
List<String> stringList = List.of("bbb");
Map<String, String> stringMap = Map.of("a-key", "a-value");
Map<String, Object> stringMap = Map.of("a-key", "a-value");
Object value = stringMap.get("a-key");
if (value instanceof String s) {
System.out.println(s.length());
}
}
}
"""
Expand Down

0 comments on commit 316f660

Please sign in to comment.