question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Create interface for access to generated filter Builder classes

See original GitHub issue

Is your feature request related to a problem? Please describe. Have many objects with same field - coding each one is tedious when I need to do something like set the default ‘statusCode’ to a standard query of int eq 0. Looking for a leaner way to do bulk query initialization in code.

Describe the solution you’d like Change the generated inner class on objects from “public static class Builder {” to something like “public static class Builder implements QBuilder” or some interface name of your choosing. This way with my 20 builder objects that I’m setting up - instead of calling builderX.setStatusCode(…) on every one I can create a method that accepts a list of QBuilder interfaces and call a generic version of the set methods that are generated. Here’s an example of the common set method implementation:

public schema.queryObj_filter.Builder withStatusCode(schema.INTEGERQueryArgument $value) {
                ((schema.queryObj_filter)RuntimeMethods.constructProxy(this._result, schema.queryObj_filter.class)).getBindings().put("statusCode", RuntimeMethods.coerceToBindingValue($value));
                return this;
            }

new interface method could be something like

@Override
public QBuilder setBinding (String $key, Object $value) {
  ((schema.queryObj_filter)RuntimeMethods.constructProxy(this._result, schema.queryObj_filter.class)).getBindings().put($key, RuntimeMethods.coerceToBindingValue($value));
  return this;
}

Generated code for all the set methods then could be changed to:

public schema.queryObj_filter.Builder withStatusCode(schema.INTEGERQueryArgument $value) {
                return setBinding("statusCode", $value);
}

Describe alternatives you’ve considered Reflection on client side would be too slow. only alternative is to have chunky code that sets the same thing on every strongly typed Builder class.

Additional context This will allow me to create code like

void setDefaultCriteria (String fieldName, IBindingsBacked query, QBuilder... filterBuilders) {
    Arrays.stream(filterBuilders).forEach(f -> f.setBinding(fieldName, query));
}

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
djchapmcommented, Oct 5, 2021

GqlBuilder interface working great for us - thanks!! This can be closed.

1reaction
rsmckinneycommented, Sep 29, 2021

@djchapm sorry about the inconvenience. As you’ve discovered method refs are not supported on structural interfaces, see https://github.com/manifold-systems/manifold/issues/30. This may be addressed in a future release, but for now lambdas are the workaround.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Create a user interface (UI) macro - Microsoft Support
You use (UI) macros to automate a series of actions, such as opening another object, applying a filter, starting an export operation, and...
Read more >
Create a dynamic filter option - ServiceNow Docs
Dynamic filter options "objectize" script includes/JavaScript, enabling them to be reused in multiple condition builders and dynamic ...
Read more >
.NET Macrofilter Interface Generator - Aurora Vision
Defines the name of the class, where all macrofilters will be available as methods (with the same signatures as macrofilters). Generate sample Microsoft...
Read more >
Understanding and using interfaces in TypeScript
A class or function can implement an interface to define the implementation of the properties as defined in that interface.
Read more >
Create an Interactive Access Form to Filter a Query by Date ...
Click OK to save and close the Expression Builder. 13. The expression you just created will now display in the Criteria row of...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found