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

refactor: refactored FeelEngineBuilder to be available from java/kotlin #832

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

vicmosin
Copy link
Contributor

Description

Refactored implementation

Related issues

closes #724

@vicmosin vicmosin requested a review from saig0 as a code owner April 19, 2024 14:16
@vicmosin
Copy link
Contributor Author

Mh.. not sure what causes this:

[INFO] Comparing to version: 1.17.5
Error:  7002: org.camunda.feel.api.FeelEngineBuilder: Method 'public scala.Function1 curried()' has been removed
Error:  7002: org.camunda.feel.api.FeelEngineBuilder: Method 'public scala.Function1 tupled()' has been removed

Copy link
Member

@saig0 saig0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vicmosin thank you for your contribution. 🎉 I added a few comments to improve the solution. Please have a look. 🍪

object FeelEngineBuilder {

@javaStatic
def create(): FeelEngineBuilder = FeelEngineBuilder()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 Nice.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Additionally, we could create a convenient method for Java applications. Usually, every Java application will use the JavaValueMapper.

For example:

def forJava(): FeelEngineBuilder = FeelEngineBuilder().withCustomValueMapper(new JavaValueMapper)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@saig0 tbh I am not sure I really understood your idea about forJava method.. Could you please elaborate?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to make it easier for Java applications. Currently, a Java application must set the JavaValueMapper to transform collections into Java types. Otherwise, the engine returns Scala types.

By providing a convenient method, a Java application doesn't need to set the value mapper itself and doesn't depend on it. Less failure points.

@saig0
Copy link
Member

saig0 commented Apr 23, 2024

@vicmosin the build failures are reported by the Clirr plugin. By adding an object to the builder, it changes the Scala internal signature. However, this is okay. We need to exclude these changes in the plugin configuration here.

class FeelEngineBuilderTest extends AnyFlatSpec with Matchers {

"A FeelEngineBuilder" should "successfully build a FeelEngineApi instance" in {
val engine: FeelEngineApi = FeelEngineBuilder.create().build()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 To verify that the builder is working from Java code, it would be best to use the builder in a Java class. In the Scala test, we could call the Java class and verify that it can build an engine.

@saig0
Copy link
Member

saig0 commented May 22, 2024

@vicmosin do you want to continue contributing to this PR? The last update was one month ago.

@vicmosin
Copy link
Contributor Author

@saig0 I am sorry, I've been busy last month, will be available at the beginning of the june. If it's urgent, feel free to take over. Thnx

@saig0
Copy link
Member

saig0 commented May 23, 2024

@vicmosin thank you for the update. 👍 No need to rush. June is fine. 🌞

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

Successfully merging this pull request may close these issues.

The FeelEngineBuilder is not usable from Java
2 participants