Skip to content

Commit f4d9d06

Browse files
committed
Replace Optional with method that takes a default value
1 parent a372a61 commit f4d9d06

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/main/java/org/openrewrite/java/migrate/UseTabsOrSpaces.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.openrewrite.java.style.TabsAndIndentsStyle;
2626
import org.openrewrite.java.tree.J;
2727
import org.openrewrite.java.tree.JavaSourceFile;
28+
import org.openrewrite.style.Style;
2829

2930
import static java.util.Objects.requireNonNull;
3031

src/main/java/org/openrewrite/java/migrate/lang/UseTextBlocks.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,14 @@
3030
import org.openrewrite.java.tree.TypeUtils;
3131
import org.openrewrite.marker.Markers;
3232
import org.openrewrite.staticanalysis.kotlin.KotlinFileChecker;
33+
import org.openrewrite.style.Style;
3334

3435
import java.security.MessageDigest;
3536
import java.security.NoSuchAlgorithmException;
3637
import java.time.Duration;
3738
import java.util.ArrayList;
3839
import java.util.Base64;
3940
import java.util.List;
40-
import java.util.Optional;
4141

4242
import static java.util.Objects.requireNonNull;
4343
import static java.util.stream.Collectors.toList;
@@ -145,7 +145,7 @@ private J.Literal toTextBlock(J.Binary binary, String content, List<J.Literal> s
145145
}
146146
}
147147

148-
TabsAndIndentsStyle tabsAndIndentsStyle = Optional.ofNullable(Style.from( TabsAndIndentsStyle.class, getCursor().firstEnclosingOrThrow( SourceFile.class ) )).orElse(IntelliJ.tabsAndIndents());
148+
TabsAndIndentsStyle tabsAndIndentsStyle = Style.from(TabsAndIndentsStyle.class, getCursor().firstEnclosingOrThrow(SourceFile.class), IntelliJ::tabsAndIndents);
149149
boolean useTab = tabsAndIndentsStyle.getUseTabCharacter();
150150
int tabSize = tabsAndIndentsStyle.getTabSize();
151151

0 commit comments

Comments
 (0)