Just like stated in title, is it possible to implement such functionality in java? Thanks.
Suppose I have a class myClass.java, is it possible to achieve below functionality
public class myClass {
@Value("{myString}")
private static String myString;
static String myStaticMethod (final Stringp[] args) {
if args.length > 0 {
retrun args[0] + myString;}
}
}
You can achieve this, BUT
@Value
annotation needs to be a non-static field, and then you can pass it to a static variable after the injection happens (if this is Spring, you can listen to a life cycle event - or change the injection to happen in the constructor)So altogether unwise, unless you are in full control of the application life cycle.