dontThrowExceptionWhenNoProperties
This commit is contained in:
@@ -59,13 +59,13 @@ public class PropertiesSerializer {
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
e.printStackTrace();
|
System.out.println("Unable to load properties from file: "+propertyFilename+". Default values will be used.");
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Field[] fields = this.getClass().getFields();
|
Field[] fields = this.getClass().getFields();
|
||||||
for (int i = 0 ; i < fields.length; i++)
|
for (int i = 0 ; i < fields.length; i++)
|
||||||
{
|
{
|
||||||
//fields[i].get(this);
|
|
||||||
String pName = fields[i].getName();
|
String pName = fields[i].getName();
|
||||||
String pType = "String";
|
String pType = "String";
|
||||||
try
|
try
|
||||||
@@ -74,20 +74,26 @@ public class PropertiesSerializer {
|
|||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
//e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
final Object myProperty = prop.get(pName);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
if (pType.equalsIgnoreCase("integer"))
|
if(myProperty==null) {
|
||||||
fields[i].set(this, Integer.parseInt(prop.get(pName) + ""));
|
System.out.println("Property "+pName+"["+pType+"] not set; input was null");
|
||||||
if (pType.equalsIgnoreCase("boolean"))
|
} else {
|
||||||
fields[i].set(this, Boolean.parseBoolean(prop.get(pName) + ""));
|
if (pType.equalsIgnoreCase("integer"))
|
||||||
else
|
fields[i].set(this, Integer.parseInt(myProperty + ""));
|
||||||
fields[i].set(this, prop.get(pName));
|
if (pType.equalsIgnoreCase("boolean"))
|
||||||
|
fields[i].set(this, Boolean.parseBoolean(myProperty + ""));
|
||||||
|
else
|
||||||
|
fields[i].set(this, myProperty);
|
||||||
|
System.out.println("Property "+pName+"["+pType+"] set to: "+myProperty);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
//e.printStackTrace();
|
// e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user