@Test public void testParseDouble() throws InvalidParameterException { assertEquals(new Double(5.2), BaleenLogging.parseToDouble(5.2)); assertEquals(new Double(5.0), BaleenLogging.parseToDouble(5)); assertEquals(new Double(5.0), BaleenLogging.parseToDouble(5L)); assertEquals(new Double(5.0), BaleenLogging.parseToDouble("5")); try { BaleenLogging.parseToDouble("Hello"); fail("Expected exception not thrown"); } catch (InvalidParameterException ipe) { } }
public static Double parseToDouble(Object obj) throws InvalidParameterException { Double ret; if (obj == null) { ret = null; } else if (Double.class.isAssignableFrom(obj.getClass())) { ret = (Double) obj; } else if (Long.class.isAssignableFrom(obj.getClass())) { Long l = (Long) obj; ret = l.doubleValue(); } else if (Integer.class.isAssignableFrom(obj.getClass())) { Integer i = (Integer) obj; ret = i.doubleValue(); } else if (String.class.isAssignableFrom(obj.getClass())) { try { ret = Double.parseDouble((String) obj); } catch (NumberFormatException nfe) { throw new InvalidParameterException("String is not numeric", nfe); } } else { throw new InvalidParameterException("Object is not numeric"); } return ret; }
BaleenLogging extends AbstractBaleenComponent { public static Double parseToDouble(Object obj) throws InvalidParameterException { Double ret; if (obj == null) { ret = null; } else if (Double.class.isAssignableFrom(obj.getClass())) { ret = (Double) obj; } else if (Long.class.isAssignableFrom(obj.getClass())) { Long l = (Long) obj; ret = l.doubleValue(); } else if (Integer.class.isAssignableFrom(obj.getClass())) { Integer i = (Integer) obj; ret = i.doubleValue(); } else if (String.class.isAssignableFrom(obj.getClass())) { try { ret = Double.parseDouble((String) obj); } catch (NumberFormatException nfe) { throw new InvalidParameterException("String is not numeric", nfe); } } else { throw new InvalidParameterException("Object is not numeric"); } return ret; } }
BaleenLogging extends AbstractBaleenComponent { public static Double parseToDouble(Object obj) throws InvalidParameterException { Double ret; if (obj == null) { ret = null; } else if (Double.class.isAssignableFrom(obj.getClass())) { ret = (Double) obj; } else if (Long.class.isAssignableFrom(obj.getClass())) { Long l = (Long) obj; ret = l.doubleValue(); } else if (Integer.class.isAssignableFrom(obj.getClass())) { Integer i = (Integer) obj; ret = i.doubleValue(); } else if (String.class.isAssignableFrom(obj.getClass())) { try { ret = Double.parseDouble((String) obj); } catch (NumberFormatException nfe) { throw new InvalidParameterException("String is not numeric", nfe); } } else { throw new InvalidParameterException("Object is not numeric"); } return ret; }  }
BaleenLogging extends AbstractBaleenComponent { public static Double parseToDouble(Object obj) throws InvalidParameterException { Double ret; if (obj == null) { ret = null; } else if (Double.class.isAssignableFrom(obj.getClass())) { ret = (Double) obj; } else if (Long.class.isAssignableFrom(obj.getClass())) { Long l = (Long) obj; ret = l.doubleValue(); } else if (Integer.class.isAssignableFrom(obj.getClass())) { Integer i = (Integer) obj; ret = i.doubleValue(); } else if (String.class.isAssignableFrom(obj.getClass())) { try { ret = Double.parseDouble((String) obj); } catch (NumberFormatException nfe) { throw new InvalidParameterException("String is not numeric", nfe); } } else { throw new InvalidParameterException("Object is not numeric"); } return ret; }  @Override void configure(Configuration yaml); static Double parseToDouble(Object obj); void configure(List<BaleenLoggerBuilder> builders); static void main(String[] args); Collection<RecentLog> getRecentLogs(); }
BaleenLogging extends AbstractBaleenComponent { public static Double parseToDouble(Object obj) throws InvalidParameterException { Double ret; if (obj == null) { ret = null; } else if (Double.class.isAssignableFrom(obj.getClass())) { ret = (Double) obj; } else if (Long.class.isAssignableFrom(obj.getClass())) { Long l = (Long) obj; ret = l.doubleValue(); } else if (Integer.class.isAssignableFrom(obj.getClass())) { Integer i = (Integer) obj; ret = i.doubleValue(); } else if (String.class.isAssignableFrom(obj.getClass())) { try { ret = Double.parseDouble((String) obj); } catch (NumberFormatException nfe) { throw new InvalidParameterException("String is not numeric", nfe); } } else { throw new InvalidParameterException("Object is not numeric"); } return ret; }  @Override void configure(Configuration yaml); static Double parseToDouble(Object obj); void configure(List<BaleenLoggerBuilder> builders); static void main(String[] args); Collection<RecentLog> getRecentLogs(); static final String DEFAULT_PATTERN; }