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

Promote renderResult method to public #1801

Merged
merged 1 commit into from May 2, 2024

Conversation

cdcarloschacon
Copy link
Contributor

This small commit makes public the "renderResult" method of the "QRCodeWriter" class.

The reason to promote this method as public is that I'm facing business case where, besides of generating the QR code as a PNG image, I also need to print information about the QR code itself (specifically, the QR version). Navigating through the code of zxing library, I noticed that the com.google.zxing.qrcode.encoder.Encoder allows me to have that (the QR metadata); however, by invoking that class I only have part of the equation (the QRCode DTO) ... I'm still needing to generate the BitMatrix in order to produce the QR image.

Here, I have two alternatives: either I invoke the Encoder.encode class by myself and repeat the same logic when invoking the QRCodeWriter.encode method; or I make the renderResult Public, call the Encoder.encode and then I proceed to call the QRCodeWriter.renderResult method with the previous result.

@srowen
Copy link
Contributor

srowen commented Apr 30, 2024

I think that's OK. My request would be to fill out javadoc for this method then, and if you have a sec, any basic unit test for the method too

@cdcarloschacon cdcarloschacon force-pushed the MakeRenderResultMethodPublic branch 2 times, most recently from c4aa812 to 27e3059 Compare May 1, 2024 07:27
@cdcarloschacon
Copy link
Contributor Author

cdcarloschacon commented May 1, 2024

@srowen , the javadoc was added to the target method and some junit tests were added too. By the way, I moved the "renderResult" method to the begin of the class, taking into consideration that it is now a public static method ...

@@ -37,6 +37,60 @@ public final class QRCodeWriter implements Writer {

private static final int QUIET_ZONE_SIZE = 4;

/**
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not against moving this, but it'd be slightly cleaner to not move the method

@cdcarloschacon
Copy link
Contributor Author

cdcarloschacon commented May 1, 2024 via email

    This small commit makes public the "renderResult" method of the
"QRCodeWriter" class.

    The reason to promote this method as public is that I'm facing
Business Case where, besides of generating the QR code as a PNG image,
I also need to print information about the QR code itself (specifically,
the QR version). Navigating through the code of zxing library, I noticed
that the com.google.zxing.qrcode.encoder.Encoder allows me to have that
(the QR metadata); however, by invoking that class I only have part of
the equation (the QRCode DTO) ... I'm still needing to generate the
BitMatrix in order to produce the QR image.

    Here, I have two alternatives: either I invoke the Encoder.encode
class by myself and repeat the same logic when invoking the
QRCodeWriter.encode method; or I make the renderResult Public, call the
Encoder.encode and then I proceed to call the QRCodeWriter.renderResult
method with the previous result.
@cdcarloschacon
Copy link
Contributor Author

The style issues were fixed ... also, the renderResult method was placed in its original location ...

@cdcarloschacon cdcarloschacon requested a review from srowen May 2, 2024 02:36
@srowen srowen merged commit 539733e into zxing:master May 2, 2024
6 checks passed
@srowen srowen added this to the 3.5.4 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants