Skip to content

Refactor operator resolution #2453

@piotrszul

Description

@piotrszul

Encapsulate operator resolution in the manner similar to function resolution.
Decide when do perform the operator resolution (maybe should be at execution time same as for functions)
or maybe the functions should be resolved at parse time as well.

See: Visitor:

  // TODO: encapsulate in operator resolver
  // Decide when do perform the operator resolution (maybe should be at execution time same as for functions)
  // or maybe the functions should be resolved at parse time as well.
  private static final Map<String, BinaryOperator> BINARY_OPERATORS = MethodDefinedOperator.mapOf(
      CollectionOperations.class);

  @Nonnull
  private FhirPath visitBinaryOperator(
      @Nullable final ParseTree leftContext,
      @Nullable final ParseTree rightContext, @Nullable final String operatorName) {
    requireNonNull(operatorName);
    return new EvalOperator(new Visitor().visit(leftContext),
        new Visitor().visit(rightContext),
        Optional.ofNullable(BINARY_OPERATORS.get(operatorName))
            .orElseGet(() -> BinaryOperatorType.fromSymbol(operatorName).getInstance()));

Metadata

Metadata

Assignees

No one assigned

    Labels

    fhirpathRelated to fhirpath reference implementationrefactoringImproving the design of existing code

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions