Skip to content

Instantly share code, notes, and snippets.

@MBoegers
MBoegers / FindUtilities.java
Last active April 15, 2025 08:42
OpenRewrite Find Utilities Receipe with Data Table
package io.github.mboegers.recipes.analyze;
import io.github.mboegers.recipes.analyze.table.Utilities;
import lombok.EqualsAndHashCode;
import lombok.Value;
import org.openrewrite.*;
import org.openrewrite.java.AnnotationMatcher;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.java.service.AnnotationService;
import org.openrewrite.java.tree.J;
@MBoegers
MBoegers / Engine.java
Last active March 13, 2025 09:41
RuleEngine with Modern Java Concurrency
import javax.net.ssl.SSLContext;
import java.security.NoSuchAlgorithmException;
import java.time.Duration;
import java.util.List;
import java.util.Map;
/// This engine uses [JEP 481](https://openjdk.org/jeps/481) {@link ScopedValue} technique to forward execution context thread save.
class Engine {
private final SSLContext sslContext;
@MBoegers
MBoegers / ShortenFullyQualifiedTypeReferencesTest.java
Created May 31, 2024 13:14
ShortenFullyQualifiedTypeReferences handling Annotations in FQN
class ShortenFullyQualifiedTypeReferencesTest implements RewriteTest {
@Override
public void defaults(RecipeSpec spec) {
spec.recipe(new ShortenFullyQualifiedTypeReferences());
}
// ommitted
@Nested
class AtAtTheBeginning {
@Test
void overwrite() {
@MBoegers
MBoegers / WithMissPaddingReproducer.java
Created June 2, 2023 11:47
Missing space before extends/implements using J.ClassDeclaration#withExtends and J.ClassDeclaration#withImpelements
package org.openrewrite.java.tree;
import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.openrewrite.ExecutionContext;
import org.openrewrite.Recipe;
import org.openrewrite.Tree;
import org.openrewrite.TreeVisitor;
import org.openrewrite.java.JavaIsoVisitor;
import org.openrewrite.marker.Markers;
import java.util.List;
class InvoiceWithModernJava {
static final String rechnungstextTemplate = """
Hallo %s,
Bitte senden Sie uns den Rechnungsbetrag in Höhe von %.2f€ plus %.2f€ MwSt.
Mit freundlichen Grüßen
Merlin Bögershausen
""";