chore(config-core): add unsafe wrapper for generating migrations since generics apparently are too much for javac
This commit is contained in:
parent
08891229a9
commit
61d622aeb1
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue