Skip to content

Conversation

@pc0202
Copy link
Owner

@pc0202 pc0202 commented Mar 21, 2019

Part1 changes done:
Introduced new methods to

  1. Field: getFunctioName(): String //parse function to get the function name from function field value
  2. Field : getArgNames(): String[] //returns array of args name from function field value of this class
  3. ViewTemplate :getExpression(String name) : String // return the result(expression) for a given function name
    Modified transformer method
    Added test cases
    deleted VTMain

Part 2 changes done-
Introduced IEvaluator: public T evaluate() and EvaluatorFactory: getInstance()

  1. Impl classes added :- ProviderEvaluator and FunctionEvaluator
  2. Added impl class SampleViewFunctionProvider (IViewFunctionProvider)
  3. SampleViewFunctionProvider : doAction() called by ProviderEvaluator:evaluate()

@pc0202 pc0202 requested a review from indrajra March 21, 2019 13:55

if (field.getDisplay()) {
result.put(field.getTitle(), evaluator.evaluate());
result.put(field.getTitle(), evaluator.evaluate().toString());
Copy link
Collaborator

Choose a reason for hiding this comment

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

The toString here can still make 7 as "7", which is why we needed some other way.

Copy link
Owner Author

Choose a reason for hiding this comment

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

Now, JsonNodeFactory.instance.pojoNode(evaluator.evaluate()) using to set the object.

@Before
public void init() {
vt = new ViewTemplate();
FunctionDefinition fd = new FunctionDefinition();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Could there be a parameterized constructor?

String mathProblem = "{\"Math\": " +
" {\"a\": 5," +
" \"b\": 2 }}";
ObjectNode node = (ObjectNode) new ObjectMapper().readTree(mathProblem);
Copy link
Collaborator

Choose a reason for hiding this comment

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

this is duplicate code repeated in tests...if you've to add a third test, you must think of creating functions for this.

Copy link
Collaborator

@indrajra indrajra left a comment

Choose a reason for hiding this comment

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

Can't allow EvaluatorFactory to be hardcoded with function names.


public class EvaluatorFactory {

public static final String concat = "concat";
Copy link
Collaborator

Choose a reason for hiding this comment

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

MANDATORY: Why are these hardcoded here? We are creating a library and this can't be in a Factory class for sure.

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.

3 participants