chore(config-core): add unsafe wrapper for generating migrations since generics apparently are too much for javac
ci/woodpecker/push/docs Pipeline was successful Details
ci/woodpecker/push/jfmod Pipeline was successful Details
ci/woodpecker/tag/docs Pipeline was successful Details
ci/woodpecker/tag/jfmod Pipeline was successful Details

This commit is contained in:
Johannes Frohnmeyer 2024-04-25 12:15:10 +02:00
parent 08891229a9
commit 61d622aeb1
Signed by: Johannes
GPG Key ID: E76429612C2929F4
1 changed files with 13 additions and 0 deletions

View File

@ -1,8 +1,21 @@
package io.gitlab.jfronny.libjf.config.api.v2.dsl;
import io.gitlab.jfronny.commons.serialize.SerializeReader;
import io.gitlab.jfronny.commons.throwable.ThrowingConsumer;
import java.util.function.Consumer;
@FunctionalInterface
public interface Migration {
static Migration of(ThrowingConsumer<SerializeReader<?, ?>, Exception> migration) {
Consumer<SerializeReader<?, ?>> safe = ((ThrowingConsumer<SerializeReader<?, ?>, RuntimeException>) (ThrowingConsumer) migration)::accept;
return new Migration() {
@Override
public <TEx extends Exception, Reader extends SerializeReader<TEx, Reader>> void apply(Reader reader) throws TEx {
safe.accept(reader);
}
};
}
<TEx extends Exception, Reader extends SerializeReader<TEx, Reader>> void apply(Reader reader) throws TEx;
}