Skip to content

Support for AND operations in EventCriteria #3343

@CodeDrivenMitch

Description

@CodeDrivenMitch

While implemented a new way to construct EventCriteria, as follows:

EventCriteria criteria = EventCriteria
    .match()
    .eventTypes("StudentRegistered")
    .withTags(Tag.of("student", "studentA"))
    .or()
    .eventTypes("StudentAssignedToCourse", "CourseRegistered")
    .withTags(Tag.of("course", "courseB"))

However, in the current API the user is unable to create and AND condition, as this would create a few logical challenges:

  1. While using the non-nested builder structure, it might be unclear which conditions you would AND.
  2. While AND is logical for tags, it is not for event types. Event types are inherently OR, as an event generallty only has one type.

To demonstrate these points, let's see the following example:

EventCriteria criteria = EventCriteria
    .match()
    .eventTypes("StudentRegistered")
    .withTags(Tag.of("student", "studentA"))
    .or()
    .eventTypes("StudentAssignedToCourse", "CourseRegistered")
    .withTags(Tag.of("course", "courseB"))
    .andAllEvents()
    .areOfTypes("StudentAssignedToCourse")

As this is an AND condition, the type of the student now has to be of both StudentRegistered and StudentAssignedToCourse to match on the student tag, this is unlikely to ever happen.
As a second problem, is the API clear enough to indicate that this AND condition wraps all other conditions?

This issue serves as marker for later investigation.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Priority 3: CouldLow priority. Issues that are nice to have but have a straightforward workaround.Status: Information RequiredUse to signal this issue is waiting for information to be provided in the issue's description.Type: EnhancementUse to signal an issue enhances an already existing feature of the project.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions