Esempio n. 1
0
 public static double getDouble(String category, String field) {
   Object property = Properties.getProperty(category, field);
   if (property instanceof Number) return ((Number) property).doubleValue();
   if (property instanceof Boolean) return ((Boolean) property).booleanValue() ? 1.0 : 0.0;
   Properties.debugException(
       "Tried to get double for invalid property! @" + property == null
           ? "(null)"
           : property.getClass().getName());
   return 0.0;
 }
Esempio n. 2
0
 public static boolean getBoolean(String category, String field, Random random) {
   Object property = Properties.getProperty(category, field);
   if (property instanceof Boolean) return ((Boolean) property).booleanValue();
   if (property instanceof Integer) return random.nextInt(((Number) property).intValue()) == 0;
   if (property instanceof Double) return random.nextDouble() < ((Number) property).doubleValue();
   Properties.debugException(
       "Tried to get boolean for invalid property! @" + property == null
           ? "(null)"
           : property.getClass().getName());
   return false;
 }
Esempio n. 3
0
 /// Gets the value of the property (instead of an Object representing it).
 public static String getString(String category, String field) {
   return Properties.getProperty(category, field).toString();
 }