Skip to content

Simplify implementation of State.isRunning()#407

Merged
eyedol merged 1 commit intoushahidi:masterfrom
alxndrsn:sync-state-isRunning-simplification
Apr 22, 2016
Merged

Simplify implementation of State.isRunning()#407
eyedol merged 1 commit intoushahidi:masterfrom
alxndrsn:sync-state-isRunning-simplification

Conversation

@alxndrsn
Copy link
Copy Markdown
Contributor

@alxndrsn alxndrsn commented Apr 7, 2016

No obvious reason to create a new EnumSet with one element each time this method is called.


public boolean isRunning() {
return EnumSet.of(SyncState.SYNC).contains(state);
return state == SyncState.SYNC;
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Though this works I prefer the SyncState.Sync.equals(state); as it reads much better to me. You using == for null safety?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Certainly is null-safe, but I was only using it because using == on enums is safe, and quicker to type ;¬) Can change to .equals() if you prefer.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I'll take safety over readability then.

@eyedol eyedol merged commit 8a966fa into ushahidi:master Apr 22, 2016
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