Hello! Wanting to ask for information on this topic as I think it might be interesting to build custom implicit constructors for Java using annotations, so then I can build a class, let's say TimeStamp and have its constructor syntax be: 12:00PM instead of something like: new TimeStamp(12, 0, "PM");
So that it behaves basically like a primitive type such as the String class, which has custom syntax to define itself: "" instead of new String(...);.
Same goes for int, double, boolean, etc.
They all have unique, implicit constructors and I'd like to build my own.
I think it would be interesting to define a unique implicit constructor via annotations with a @ConstructorRule annotation
For example, TimeStamp's implicit constructor could be:@ConstructorRule(int:int (PM|AM))And a Data implicit constructor could look like: @ConstructorRule(int/int/int)(Possibly with some more rules to limit to 2 digits/2 digits/4 digits?)
Whitespace would be ignored.
So you could define primitive types as "parameters" to the implicit constructor, then characters/strings (such as :/PM/AM in TimeStamp or f in C#'s float)
Could be a cool feature for Java, but it could also make Java fairly unreadable if one is not aware of the added syntax rules made by the @ConstructorRule annotation
It's not really super useful per-say and doesn't add anything that can't be done with vanilla constructors, but it would look cool!
Is this possible with the current state of annotations? How would I go about starting to structure this annotation? What should I look out for when starting this project?
