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

Make CertRecordPagedList generic #4662

Merged
merged 1 commit into from
Jan 29, 2024

Conversation

fmarco76
Copy link
Member

The class CertRecordPagedList is renamed to RecordPagedList and made generic to be used with all type of entries available.

The class `CertRecordPagedList` is renamed to `RecordPagedList` and made
generic to be used with all type of entries available.
@fmarco76 fmarco76 requested a review from edewata January 29, 2024 11:27
Copy link

Quality Gate Passed Quality Gate passed

The SonarCloud Quality Gate passed, but some issues were introduced.

3 New issues
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code

See analysis details on SonarCloud

Copy link
Contributor

@edewata edewata left a comment

Choose a reason for hiding this comment

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

LGTM. Please see my comment about a possible future improvement.

Comment on lines 120 to 123
DBSearchResults sr = new DBSearchResults(registry, res);
while (sr.hasMoreElements()) {
entries.add((CertRecord) sr.nextElement());
entries.add(contentClassType.cast(sr.nextElement()));
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suppose we can use generics in DBSearchResults as well, we might not need the contentClassType.

ArrayList<E> entries = new ArrayList<>();
DBSearchResults<E> sr = new DBSearchResults<>(registry, res);
entries.add(sr.nextElement());

Copy link
Member Author

Choose a reason for hiding this comment

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

I tried this approach but eclipse and java was complaining because add() is expecting an object from class E. With generic you cannot do dynamic type cast either entries.add((E) sr.nextElement()). The option I have investigated are:

  • suppressing all the possible warning
  • creating a custom class handling the the runtime type using reflection
  • provide the runtime type

I opted for the last one because it looks the cleaner and safer to implement but if we found better approaches we can always improve.

@fmarco76 fmarco76 merged commit 45200b4 into dogtagpki:master Jan 29, 2024
133 checks passed
@fmarco76
Copy link
Member Author

@edewata Thanks!

@fmarco76 fmarco76 deleted the MakePageSearchGeneric branch February 21, 2024 17:34
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