Closed 1057105012 closed 1 year ago
Does that code make any sense at all?
let order = {
name: "book"
price: "22.3"
}
patchBook({book: "11", price: "22"})
To assign a value to something that is not even a field. The field is "name", not "book". If that makes sense -> "I don't want to live in this javascript world anymore." Dr'. Hubert EcmasWorth.
I'm just giving an example. In fact, what I want to express is whether Java can be more free in constructing objects and operating assignments. My example may not be very expressive, but you should be able to understand what I want to express. What I want to express is that Java can use lombok to allow these writing methods when writing code, and there is no need to create a hashMap to do this kind of thing. One use is that when passing context across threads, you no longer need to use map.get("foo"), but can directly use ctx.foo like this. The main reason is that it will be much more convenient to write code to support this feature, and it is often encountered in Java. The operation of patching objects, and sometimes even having to construct some iterative classes that are not very useful
var foo = { foo: 'aaa', bar: 'bbb', count: 33 };
So what you want is something like "autoboxing/unboxing" for maps? (btw: you might like to revise your examples, as they are confusing, because they seem to be syntactically inconsistent/incorrect -- that makes it hard to understand your point IMHO)
I can't say if the Lombok developers would be willing to include such a feature, but one technical limitation that would prevent it might be that Lombok joins in with the compiler and modifies the syntax tree. If I'm not wrong that means the java source code has already been parsed and been organized into tokens. If that's the case all extras Lombok can offer are constrained by the general Java grammar. I fear there's nothing in the Java grammar that could parse {foo: "bar"}
, so that would be a dead end, and thus your feature request would be impossible to realize within the boundaries of Lombok's approach.
But I don't know enough about Lombok's internals, so someone more knowledgeable hopefully can bring some enlightenment into this.
This is so far removed from what java can do, the answer is an empathic no and I'm shutting the debate down. If you want to discuss what this would look like, feel free. But not in an issue on this project.
When we write js code, we will notice the following code
Lombok can simulate this behavior at the Java level. Using idea support, I believe many people need it!