Open lantunes opened 10 years ago
The type MyEntity in the example above would have to be fully qualified, and given with its package name. So the example would become "Hello from [my.package.MyEntity.someProperty]". Otherwise, how could the type be resolved with just the simple name?
One option might be to provide the type to be interpolated elsewhere, such as a map, and the MyEntity type in the string could be replaced by an alias corresponding to a key in the map. So, the example could be "Hello from [entity.someProperty]", and a map would exist with {"entity" -> MyEntity.class}.
We'd be better off using different delimiters for the bean properties. For instance, the example could become "Hello from #(entity.someProperty)", where "#(" and ")" are the delimiters.
We could define aliases for types by registering them with the server:
server.register(MyEntity.class).withAlias("entity");
Then we can access them in the interpolated string: "Hello from #(entity.someProperty)".
Would it be useful to access unmarshalled entities through interpolation?
For example, a usage might be "Hello from [MyEntity.someProperty]", where MyEntity indicates that the request body should be unmarshalled using the MyEntity type, and someProperty reflectively accesses a JavaBean property called "someProperty" on the MyEntity instance. The property should have a return type, and the return value's toString() method will be invoked.