it's not a big programming problem, but I'm curious if it should be done better. So I have a config file which I'm reading via
java.util.Properties class. When property is not present in a file
getProperty() method returns null. I would like to throw an exception if any property is not present in config file. So how should I do it?
Two ideas comes to mind, but I think there should be other way to do it. The first is that after every call of
getProperty() I would do
if (prop == null) throw new SomeException, but it wouldn't look nice if there would be identical ifs after every two lines. Second approach is to make one big
if after all properties are read and just check them all at once.