-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Added support for javaType on integer and number properties. #287
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
Added support for javaType on integer and number properties. #287
Conversation
Ha, so it is. A bit of archeology needed :) Thanks for submitting this! I'll give it a look over and merge tomorrow. |
Thanks @joelittlejohn ! |
Took a quick look at #41, and no this is not a regression of that change. That change relates to being able to specify primitive types when you use the javaType property inside 'object'. I'm interested to know what prompted you to make this change. Did you need to change the type of specific properties and not want to change the configuration globally with useLongIntegers/useDoubleNumbers/usePrimitives? |
@joelittlejohn I needed most of my My current project is polyglot and we are using JSON Schema as a way of keeping our interfaces sane. I am starting to have a lot of schemas in my build, so fine grained control over things like is coming up more frequently. |
Totally willing to work on this some, if you think the implementation needs to be different. |
Hi Christian. Looks great to me. Lots of tests too so I'm perfectly happy to merge. To be perfectly honest, I probably would have left this as an unconstrained option and simply used whatever type is found in javaType. E.g. If I want to use BigInteger/BigDecimal I could use that, or maybe my own custom type (as long as I give Jackson a serializer/deserializer for my custom type, it'll work). I'm happy to go with these constraints though as they make sense in most cases. If anyone feels limited by them, we can relax it in a later version. |
Do you already have a method around that operates like Class.forName(String), but handles primitives like |
This class may help: You could use a check like |
Cool. Let me take a look at this real quick and add a commit for it. If it looks good, we can squash. If it sucks, we can drop the commit. Would like this to be done right. |
@joelittlejohn the implementation is generalized. Let me know what you think and I can clean up the history. |
Looks good. Squash away and I'll merge tomorrow. Thanks again for all your contributions! |
da28479
to
ad1f56b
Compare
Squashed and ready to merge. |
Added support for javaType on integer and number properties.
This PR adds support for the
javaType
oninteger
andnumber
properties.integer
supports the followingjavaType
values:int
java.lang.Integer
long
java.lang.Long
number
supports the followingjavaType
values:float
java.lang.Float
double
java.lang.Double
When
javaType
is present, the configuration settings are ignored.