I can never remember the syntax for passing a method reference in Java, so I'm pasting a note about it here. Here is a decent link explaining the idea.
Here is a method that accepts a method reference as a parameter, and calls that method in its body:
protected ItemDomainEntity findByPath_(String path, Function<ItemDomainEntity, ItemDomainEntity> parentGetterMethod) {
<snip>
ItemDomainEntity candidateParent = parentGetterMethod.apply(candidateItem);
<snip>
}
And then an example of calling that method:
findByPath_(path, ItemDomainMachineDesign::getParentMachineDesign);
No comments:
Post a Comment