Skip to content
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

[Improve] Optimize EntityStatus enum #1602

Closed
2 tasks done
ruanwenjun opened this issue Oct 10, 2021 · 0 comments · Fixed by #1603
Closed
2 tasks done

[Improve] Optimize EntityStatus enum #1602

ruanwenjun opened this issue Oct 10, 2021 · 0 comments · Fixed by #1603

Comments

@ruanwenjun
Copy link
Member

Description

  1. Since we use contains to judge the status, it's better to use Set rather than List, and this also make the code consistent with other enums, in other enums, they all use set.
// Determine whether the current state can be deleted
  if (!EntityStatus.ALLOW_DELETE_BIZ_STATUS.contains(entity.getStatus())) {
      LOGGER.error("current status was not allowed to delete");
      throw new BusinessException(BizErrorCodeEnum.BUSINESS_DELETE_NOT_ALLOWED);
  }

https://github.com/apache/incubator-inlong/blob/73d149610e1d88913a65529a5bb003bf1ea058a7/inlong-manager/manager-common/src/main/java/org/apache/inlong/manager/common/enums/EntityStatus.java#L72-L114

  1. We can create an util to transform collection to ImmutableMap, currently, there are some duplicate code.

Use case

No response

Are you willing to submit PR?

  • Yes, I am willing to submit a PR!

Code of Conduct

@dockerzhang dockerzhang added this to the 0.11.0 milestone Oct 11, 2021
@aloyszhang aloyszhang changed the title [Feature] Optimize EntityStatus enum [Improve] Optimize EntityStatus enum Oct 22, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants