Comments (5)
try scalabeans. it has also bean builder, you provide it with property values you have and it figures how to create new bean instance with them: either via constructor args or by assigning property values or by combination of both.
from jackson-module-scala.
Thanks for the tip; I'd been exploring the ScalaSigParser in scalap, but the API in scalabeans looks much friendlier
from jackson-module-scala.
What do auto-generated properties look like? Since it is possible to figure out which classes are case classes, it should be possible to construct scala-specific AnnotationIntrospector to change definition of how property names are introspected for fields. This also applies to implicit get/set methods (set ones end with '='?).
from jackson-module-scala.
That's the approach I'd tried to take with scalap, but the API wasn't nearly as convenient. I've managed to get a very simple test case working with just constructor arguments. I'm going to take a stab at extending it for read/write properties outside the constructor before committing.
from jackson-module-scala.
Properties have auto-generated getter with the same name as property and setter with "_$eq" suffix. Setters are generated only for mutable properties (var). Variables (val/var) are in the same symbol space as methods in Scala (in contrast with Java), ie there cannot be both variable and method with the same name. When using Java reflection method can be distinguished from val by looking at the presence of private field with the same name.
There are some other interesting situations like "synthetic" properties (having explicit getter/setter in Scala code), constructor parameters, properties derived from superclasses. They might have slight variations of described pattern.
Another peculiarity is that since Scala 2.9 in some situations Scala types are seen from Java reflection as just Object. For example, Option[Int]
becomes Option<Object>
in Java reflection. So, using ScalaSig is inevitable to get the right property type.
This all applies to all Scala classes, of course, not only to case classes.
from jackson-module-scala.
Related Issues (20)
- Release 2.15.2 HOT 2
- Dependency on .class and .tasty files causes footprint bloat for GraalVM NativeImage HOT 5
- Failure to deserialise scala Map when default typing is activated HOT 10
- DefaultScalaModule breaks deserialization of java classes HOT 13
- 2.16 jackson-databind deserialization changes have broken support for the scala.util.Either class HOT 1
- Collection of case classes deserialized as Collection of Map2 HOT 4
- Release 2.15.3 HOT 4
- Release 2.16.0-rc1 HOT 1
- error when deserializing yaml HOT 2
- Release 2.16.0 HOT 2
- release jackson-module-scala v2.12 for Scala 2.10 HOT 2
- Release 2.16.1 HOT 1
- Update `2.17` branch to `2.17.0-rc1-SNAPSHOT` HOT 2
- Release 2.15.4 HOT 1
- Release 2.17.0-rc1 HOT 1
- Release 2.16.2 HOT 2
- Release 2.17.0 HOT 2
- Performance regression with 2.17.x HOT 32
- Update 2.17 release note wiki with Scala module 2.17 fixes HOT 4
- Release 2.17.1 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from jackson-module-scala.