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

Add new DefaultBinding(Binding<T, U>) constructor #11964

Closed
lukaseder opened this issue Jun 4, 2021 · 0 comments
Closed

Add new DefaultBinding(Binding<T, U>) constructor #11964

lukaseder opened this issue Jun 4, 2021 · 0 comments

Comments

@lukaseder
Copy link
Member

The org.jooq.impl.DefaultBinding type is currently used for 3 purposes:

  • As a namespace for all internal bindings
  • As a legacy implementation for DefaultBinding(Converter<T, U>) (now deprecated)
  • As a default implementation for other bindings that delegate to an internal delegate

That last bit could be useful for users as well. We have a lot of DefaultXYZ types that wrap a delegate object and delegate to the latter by default, on all methods.

For example, users can now write:

class AlwaysInlineBinding<T> extends DefaultBinding<T, T> {
    public AlwaysInlineBinding(DataType<T> type) {
        super(DefaultBinding.binding(type));
    }

    @Override
    public void sql(BindingSQLContext<T> ctx) throws SQLException {
        ctx.render().visit(inline(ctx.value()));
    }
}

And now use that binding like any other binding, but it will only ever inline all bind values

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
No open projects
Development

No branches or pull requests

1 participant