The final keyword is unnecessary. Not only from a technical perspective as final complex objects can still be manimulated (e.g. call clear on a final list) but also from a theoretical perspective.
In functional programming a function (in this case your lambda) is not supposed to manipulate structures. Execution is not happening by changing the state of structures as a side effect but by returning new structures that contain a new state. Therefore input parameters should never be manipulated.
Moreover, for a filter, I would never expect that it manipulates a structure even if I have never heard of functional programming. Therefore the final is unnecessary.
For the type there can be some benefit by explicitly declaring it. However, instead of writing 'Member m -> ...' I would rather use a meaningful variable name and write 'member -> ...'. In this example this does not change much but sometimes you might be forced to cope with enterprise-style class names like 'AbstractOracleDatabaseAccessSerializer' which you cant change but definitely do not want to write all the time. (Please do not start a discussion on the names here. This is example is not helpful but I am sure it exists in real life ;))
So in your case I would probably do something like this
Bot.getGuild().getMembers().stream()
.filter(member -> member.getRoles().size() == 0)
.filter(member -> !member.getUser().isBot())
.forEach(JoinListener::assignDefaultRole);
As a side note, when you have multiple filters in a row, I might make sense to combine them into a single filter function on the member class if the filter is needed more often or the filter condition is a concept of the Member class. This would enable you to use a member reference instead
Bot.getGuild().getMembers().stream()
.filter(Member::checkXXX)
.forEach(JoinListener::assignDefaultRole);
final
makes little difference. It would also highlights the strangeness of theassignDefaultRole
andgetGuild
static methods.for (final Member m : Bot.getGuild().getMembers()) { if (m.getRoles().isEmpty() && !m.getUser().isBot()) { JoinListener.assignDefaultRole(m); } }
.