Skip to content

Add BiConsumer support in AssociationLinker #1327

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

Merged
merged 1 commit into from
May 5, 2025
Merged

Conversation

nakamura-to
Copy link
Member

@nakamura-to nakamura-to commented May 5, 2025

This pull request introduces support for the BiConsumer functional interface in the AssociationLinker, alongside the existing BiFunction support. This enhancement expands the flexibility of AssociationLinker to handle operations requiring BiConsumer types. No additional features or breaking changes are introduced.

This pull request makes it possible to write an interface annotated with AggregateStrategy as follows:

@AggregateStrategy(root = Emp.class, tableAlias = "e")
interface EmpStrategy {
  @AssociationLinker(propertyPath = "dept", tableAlias = "d")
  BiConsumer<Emp, Dept> dept = (e, d) -> {
    e.dept = d;
    d.employees.add(e);
  };

  @AssociationLinker(propertyPath = "address", tableAlias = "a")
  BiConsumer<Emp, Address> address = (e, a) -> {
    e.address = a;
  };
}

Before this pull request, it was necessary to write it like this:

@AggregateStrategy(root = Emp.class, tableAlias = "e")
interface EmpStrategy {
  @AssociationLinker(propertyPath = "dept", tableAlias = "d")
  BiFunction<Emp, Dept, Emp> dept = (e, d) -> {
    e.dept = d;
    d.employees.add(e);
    return e;
  };

  @AssociationLinker(propertyPath = "address", tableAlias = "a")
  BiFunction<Emp, Address, Emp> address = (e, a) -> {
    e.address = a;
    return e;
  };
}

This update introduces `BiConsumer` as a valid type for `AssociationLinker` in addition to `BiFunction`.
@nakamura-to nakamura-to merged commit faeebad into master May 5, 2025
13 checks passed
@nakamura-to nakamura-to deleted the feat/bi-consumer branch May 5, 2025 09:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant