Is it possible in Java to get a name of field in string from the actual field? like:
public class mod {
@ItemID
public static ItemLinkTool linkTool;
My motivation at getting the field name is using it to search for things in a key-value database (like mongodb). I have a struct with members (fields) that represents the saved data. I use the member names to search the db.
My suggestion is to put a static getter for each important member. Example:
public class Data {
public static String getMember1Key() {
return "member1";
}
public String member1;
}
Hopefully, Java will have some mechanism for this in the future, because nowadays, the metadata may be part of the data. Especially when doing stuff with JSON.