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

add the namespace mapping capability of avrohugger #13

Closed
wants to merge 2 commits into from

Conversation

shudas
Copy link

@shudas shudas commented Oct 23, 2017

Avro Hugger has the ability to change the namespace of the generated scala source files.
https://github.com/julianpeeters/avrohugger#customizable-namespace-mapping

This PR exposes this mapping functionality.

@makubi
Copy link
Owner

makubi commented Oct 25, 2017

Hi @shudas,

thank you very much for the feature implementation.

I am going to review the PR right now.

@makubi makubi self-assigned this Oct 25, 2017
Copy link
Owner

@makubi makubi left a comment

Choose a reason for hiding this comment

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

Could you add one test for the feature?

Thanks!

@@ -52,7 +58,20 @@ public void execute() throws MojoExecutionException, MojoFailureException {
String outputDirectoryPath = outputDirectory.getAbsolutePath();
getLog().info("Generating Scala files for schemas in " + sourceDirectoryPath + " to " + outputDirectoryPath);

Map<String, String> nonNullNamespaceMapping = new HashMap<>();
if (namespaceMapping != null && !namespaceMapping.isEmpty()) {
Copy link
Owner

Choose a reason for hiding this comment

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

What do you think about using an empty List as default value? This would remove the null check.
You can remove the if statement completely as for empty Lists the code would be executed zero times.

Please also move the transformation to Map to the AvrohuggerGenerator class since we need a Scala Map anyways.

@@ -0,0 +1,6 @@
package at.makubi.maven.plugin.avrohugger;

public class mapping {
Copy link
Owner

Choose a reason for hiding this comment

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

Please rename the class to start with an upper-case like Mapping.

package at.makubi.maven.plugin.avrohugger;

public class mapping {
String from;
Copy link
Owner

@makubi makubi Oct 25, 2017

Choose a reason for hiding this comment

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

I am not sure, if this works or if you need to use a POJO with setters and getters.

Copy link
Author

Choose a reason for hiding this comment

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

I tested it out myself and this works.

@shudas
Copy link
Author

shudas commented Oct 26, 2017

Hi, I've made the changes you have asked for. Thanks for the quick PR

Copy link
Owner

@makubi makubi left a comment

Choose a reason for hiding this comment

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

Thanks for updating the PR.

Can you please use another (meaningful) branch than master as source branch and squash the commits to one?

Thanks

</executions>
<configuration>
<namespaceMapping>
<Mapping>
Copy link
Owner

Choose a reason for hiding this comment

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

For convenience, can you change the example doc to mapping with a lower case? I guess this should work with the upper case Mapping class name.

@@ -19,6 +19,12 @@
<recursive>true</recursive>
<limitedNumberOfFieldsInCaseClasses>true</limitedNumberOfFieldsInCaseClasses>
<sourceGenerationFormat>STANDARD</sourceGenerationFormat>
<namespaceMapping>
<Mapping>
Copy link
Owner

Choose a reason for hiding this comment

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

And update it here as well.

@shudas shudas mentioned this pull request Oct 31, 2017
@shudas
Copy link
Author

shudas commented Oct 31, 2017

In order to change the base branch name, it looks like I had to open a new PR against master. #15

Please approve that one and I will close this, and squash and merge that one.

@makubi
Copy link
Owner

makubi commented Nov 2, 2017

Just squash the three commits at the new PR and close this one, then I will approve it.

@shudas shudas closed this Nov 13, 2017
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.

None yet

2 participants