Package com.google.gson.internal

Examples of com.google.gson.internal.LazilyParsedNumber


    private static Number unwrapNumber(Number n) {
        Number unwrapped;

        if (n instanceof LazilyParsedNumber) {
            LazilyParsedNumber lpn = (LazilyParsedNumber) n;
            BigDecimal bigDecimal = new BigDecimal(lpn.toString());
            if (bigDecimal.scale() <= 0) {
                if (bigDecimal.compareTo(new BigDecimal(Integer.MAX_VALUE)) <= 0) {
                    unwrapped = bigDecimal.intValue();
                } else {
                    unwrapped = bigDecimal.longValue();
View Full Code Here


        bundle = HttpStatsDIngestionHandler.createBundle(json);
    }
   
    @Test(expected = NumberFormatException.class)
    public void testExpectedGsonConversionFailure() {
        new LazilyParsedNumber("2.321").longValue();
    }
View Full Code Here

        new LazilyParsedNumber("2.321").longValue();
    }
   
    @Test
    public void testGsonNumberConversions() {
        Number doubleNum = new LazilyParsedNumber("2.321");
        Assert.assertEquals(Double.parseDouble("2.321"), PreaggregateConversions.resolveNumber(doubleNum));
       
        Number longNum = new LazilyParsedNumber("12345");
        Assert.assertEquals(Long.parseLong("12345"), PreaggregateConversions.resolveNumber(longNum));
    }
View Full Code Here

   * @return get this element as a Number.
   * @throws NumberFormatException if the value contained is not a valid Number.
   */
  @Override
  public Number getAsNumber() {
    return value instanceof String ? new LazilyParsedNumber((String) value) : (Number) value;
  }
View Full Code Here

   * @return get this element as a Number.
   * @throws NumberFormatException if the value contained is not a valid Number.
   */
  @Override
  public Number getAsNumber() {
    return value instanceof String ? new LazilyParsedNumber((String) value) : (Number) value;
  }
View Full Code Here

    return this.value instanceof Number;
  }

  public Number getAsNumber()
  {
    return (this.value instanceof String) ? new LazilyParsedNumber((String)this.value) : (Number)this.value;
  }
View Full Code Here

    return this.value instanceof Number;
  }

  public Number getAsNumber()
  {
    return (this.value instanceof String) ? new LazilyParsedNumber((String)this.value) : (Number)this.value;
  }
View Full Code Here

TOP

Related Classes of com.google.gson.internal.LazilyParsedNumber

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.