Open GoogleCodeExporter opened 8 years ago
...this is an enhancement request not a defect.
Original comment by mark.a...@gmail.com
on 30 Oct 2012 at 7:58
"Hopefully this feature is easy to implement because its benefits would be
enormous."
It is easy to implement. I've already done something similar with an internal
library I use.
All of the hibernate validations can easily be supported.
I generally use field annotations for validation, and options for everything
else.
Here's how it would look like:
package sample;
option raw_java_import = "
import com.company.AnotherClassAnnotation;
";
message Greet {
option raw_java_annotation = "
@com.company.MyClassAnnotation
@AnotherClassAnnotation
";
optional int32 id = 1;
@NotBlank // doesn't need an import, your codegenerator already knows all the possible annotations
optional string name = 2;
@NotBlank
@Size(min=2, max=32)
optional string message = 3;
enum Status {
NEW = 0;
ACKNOWLEDGED = 1;
}
optional Status status = 4;
}
"From view layer all the way to the data layer".
I use it on all layers (persistence, validation, rpc, views/widgets) on both
sides (client/server)
Original comment by david.yu...@gmail.com
on 31 Oct 2012 at 3:58
That's fantastic. The only concern is the generator knowing about possible
annotations. This is fine for current hibernate implementation but any new
annotations in hibernate will require the generator to be updated. Knowing all
possible annotations is a nice convince feature but we should also let users
explicitly import and define field level annotations.
Can you give us a time-table as to when we should expect your code to be merged
and this feature request implemented?
Original comment by mark.a...@gmail.com
on 31 Oct 2012 at 12:08
"but any new annotations in hibernate will require the generator to be updated"
Yes, though its not really a problem for me.
"Can you give us a time-table as to when we should expect your code to be
merged and this feature request implemented?"
There aren't any plans to merge it. All my codegen add-ons are specific to my
application/framework and would need some extra work to extract it.
Maybe in the future when it is more polished ... but not at the moment.
You might wanna try getting familiar with the parser/compiler api and try to
implement something like the example I showed you.
There have been a few people on the mailing list that used the DSL for their
internal frameworks (some shared part of their code)
http://code.google.com/p/protostuff/wiki/JavaBeanModelCompiler
Original comment by david.yu...@gmail.com
on 31 Oct 2012 at 5:05
Original issue reported on code.google.com by
mark.a...@gmail.com
on 30 Oct 2012 at 7:45