harmonica
harmonica copied to clipboard
Java support
Is it possible to use this library with Java language? It will increase the popularity if it will possible to use it also in Java and have Kotlin DSL
@raderio
I guess it is available to use this library with Java, but I have not tried.
@raderio What kind of support do you expect?
@raderio Hi, how is it going? If writing migration classes in Java, they will be something like this.
package com.improve_future.harmonica_test.jarmonica.migration;
import com.improve_future.harmonica.core.AbstractMigration;
import com.improve_future.harmonica.core.table.TableBuilder;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
public class M2020012345678_Migration extends AbstractMigration {
@Override
public void up() {
createTable("test_table", new Function1<TableBuilder, Unit>() {
@Override
public Unit invoke(TableBuilder tableBuilder) {
tableBuilder.integer("integer_column", false, (long) 10, false);
return Unit.INSTANCE;
}
});
}
@Override
public void down() {
}
}
As a Kotlin feature, Kotlin can coexist in Java projects. So you can write it in Kotlin even if your project is in Java.
References
- https://stackoverflow.com/questions/53123217/call-higher-order-function-of-kotlin-from-java