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

Adding Single Int Constructor Support (Issue #25) #121

Closed

Conversation

Shounaks
Copy link
Contributor

@Shounaks Shounaks commented Feb 22, 2024

(Issue #25)
this already had a failing test (we should add this tag)

@Shounaks Shounaks force-pushed the 2.17-singleint-constructor-support branch from 205fef7 to b4e6fa3 Compare February 22, 2024 03:30
@Shounaks Shounaks marked this pull request as ready for review February 22, 2024 03:32
Set<String> ignorableNames, Map<String, String> aliasMapping)
{
super(type);
_propsByName = props;
_defaultCtor = defaultCtor;
_stringCtor = stringCtor;
_longCtor = longCtor;
_intCtor = intCtor;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe propogation of HashMap<FIRST_ARG,CONSTRUCTOR> should be a better alternative, to support future items. instead of adding individually in all the following files.

Copy link
Member

Choose a reason for hiding this comment

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

I agree with the general idea (could use EnumMap too), but how about going even more OO and have Constructors (or whatever its named) container that encapsulates these details?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried using enum map, but that would require us explicitly manage a list of supported items, with the code getters and setters; a problem not present in HashMap.

@@ -6,12 +6,12 @@
// for [jackson-jr#25], allowing single-int constructors
public class ReadWithCtors25Test extends TestBase
Copy link
Contributor Author

Choose a reason for hiding this comment

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

need to move this to passing tests, once the implementation is approved

cowtowncoder added a commit that referenced this pull request Feb 23, 2024
@cowtowncoder cowtowncoder added the has-failing-test Indicates that there exists a test case (under `failing/`) to reproduce the issue label Feb 23, 2024
Copy link
Member

@cowtowncoder cowtowncoder left a comment

Choose a reason for hiding this comment

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

Ok, yes, this makes sense -- but I think the idea of creating separate container class for different constructors makes sense: can then pass that object instead of 4 constructors (plus obv easier extension in future, as necessary).

With that I'll be happy to merge this!

@@ -0,0 +1,29 @@
package com.fasterxml.jackson.jr.ob.impl;
Copy link
Member

@cowtowncoder cowtowncoder Feb 23, 2024

Choose a reason for hiding this comment

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

Um, sorry, but this looks unnecessarily complicated: instead of Map, suppliers etc, let's just stick to plain old typed fields. Map adds overhead while not improving readability.

Same goes for exception, construction: straight-forward non-generalized construction, exception.

@cowtowncoder
Copy link
Member

Thank you for contributing this PR! I created slightly modified one based on my preferences wrt Constructor collector, merged: since it is based on your code I put you as the author in release notes.

I'll close this PR as done.

Shounaks pushed a commit to Shounaks/jackson-jr that referenced this pull request Feb 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
has-failing-test Indicates that there exists a test case (under `failing/`) to reproduce the issue
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants