Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Java support #147

Open
raderio opened this issue Mar 21, 2020 · 3 comments
Open

Java support #147

raderio opened this issue Mar 21, 2020 · 3 comments

Comments

@raderio
Copy link

raderio commented Mar 21, 2020

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

@KenjiOhtsuka
Copy link
Owner

@raderio

I guess it is available to use this library with Java, but I have not tried.

@KenjiOhtsuka
Copy link
Owner

@raderio
What kind of support do you expect?

@KenjiOhtsuka
Copy link
Owner

@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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants