Skip to content

Conversation

@yvasyliev
Copy link

Message#isCommand felt lonely, so I added Message#getCommand for company

@yvasyliev yvasyliev changed the base branch from master to dev June 21, 2025 13:48
public String getCommand() {
return Stream.ofNullable(entities)
.flatMap(Collection::stream)
.filter(entity -> entity != null && NumberUtils.INTEGER_ZERO.equals(entity.getOffset()))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't think we need a whole new import to check a number vs 0

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's nothing wrong with importing constants. It's a bad practice to use magic numbers.

@yvasyliev yvasyliev requested a review from rubenlagus July 24, 2025 09:44
@rubenlagus rubenlagus force-pushed the dev branch 3 times, most recently from 52a184e to 9203912 Compare September 7, 2025 22:52
…tter performance in `Message#getCommand` method
@yvasyliev
Copy link
Author

yvasyliev commented Dec 27, 2025

Hi @rubenlagus

  1. I replaced the Stream block with plain for loop for slightly better performance.
  2. entity.offset is an Integer, meaning just comparing it to 0 is not null-safe. Still NumberUtils.INTEGER_ZERO could be handy here (commons-lang3 is already included into the project). I decided to put Objects.equals(entity.getOffset(), 0) instead of entity.getOffset() != null && entity.getOffset() == 0 if that's fine.

Could you please review the PR?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants