Reputation:
I have this static method which returns a string from a yml file by given parameters. I use this in over 20 classes and currently I just paste this code into each class. Is there better way to access that method from each class without needing to copy paste it all over? Thanks in advance.
private static String msgYml(String message) {
return ConfigMgr.getMessages().getString(message);
}
Upvotes: 0
Views: 37
Reputation: 40078
You can create a static method in util
class that accepts ConfigMgr
and String
, so you can pass the appropriate ConfigMgr
public class YamlUtil {
public static String getYmlProps(ConfigMgr configMgr, String prop) {
return configMgr.getMessages().getString(prop);
}
}
Upvotes: 2