/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as an * unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ @CanIgnoreReturnValue public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as an * unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ @CanIgnoreReturnValue public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as an * unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ @CanIgnoreReturnValue public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
@GwtIncompatible // too slow public void testEquals() { EqualsTester equalsTester = new EqualsTester(); for (long a : TEST_LONGS) { BigInteger big = (a >= 0) ? BigInteger.valueOf(a) : BigInteger.valueOf(a).add(BigInteger.ZERO.setBit(64)); equalsTester.addEqualityGroup( UnsignedLong.fromLongBits(a), UnsignedLong.valueOf(big), UnsignedLong.valueOf(big.toString()), UnsignedLong.valueOf(big.toString(16), 16)); } equalsTester.testEquals(); }
/** * Reads a timestamp that is the number of hundreds of nanoseconds since Jan 1 1601 * (see http://integriography.wordpress.com/2010/01/16/using-phython-to-parse-and-present-windows-64-bit-timestamps/) * * @return the date corresponding to the timestamp */ public Date readFileTime() { UnsignedLong hundredsOfNanosecondsSinceJan11601 = readQWord(); long millisecondsSinceJan11601 = hundredsOfNanosecondsSinceJan11601.dividedBy(UnsignedLong.valueOf(10000)).longValue(); long millisecondsSinceEpoch = millisecondsSinceJan11601 - EPOCH_OFFSET; return new Date(millisecondsSinceEpoch); }
public void testValueOfBigInteger() { BigInteger min = BigInteger.ZERO; BigInteger max = UnsignedLong.MAX_VALUE.bigIntegerValue(); for (BigInteger big : TEST_BIG_INTEGERS) { boolean expectSuccess = big.compareTo(min) >= 0 && big.compareTo(max) <= 0; try { assertEquals(big, UnsignedLong.valueOf(big).bigIntegerValue()); assertTrue(expectSuccess); } catch (IllegalArgumentException e) { assertFalse(expectSuccess); } } }
public void testValueOfLong() { for (long value : TEST_LONGS) { boolean expectSuccess = value >= 0; try { assertEquals(value, UnsignedLong.valueOf(value).longValue()); assertTrue(expectSuccess); } catch (IllegalArgumentException e) { assertFalse(expectSuccess); } } }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as * an unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as * an unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as * an unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as * an unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as * an unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as * an unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as * an unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as * an unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
@Override public UnsignedLong decode(String value) { checkNotNull(value, "Null values are not allowed"); return valueOf(value); } }
/** * Returns an {@code UnsignedLong} holding the value of the specified {@code String}, parsed as an * unsigned {@code long} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code long} * value */ @CanIgnoreReturnValue public static UnsignedLong valueOf(String string) { return valueOf(string, 10); }
protected static Sample toSample(AbstractDS ds, Resource resource, Timestamp timestamp, double value) { final String metric = ds.getName(); final MetricType type = ds.isCounter() ? MetricType.COUNTER : MetricType.GAUGE; final ValueType<?> valueType = ds.isCounter() ? new Counter(UnsignedLong.valueOf(BigDecimal.valueOf(value).toBigInteger())) : new Gauge(value); return new Sample(timestamp, resource, metric, type, valueType); }
@GwtIncompatible // too slow public void testEquals() { EqualsTester equalsTester = new EqualsTester(); for (long a : TEST_LONGS) { BigInteger big = (a >= 0) ? BigInteger.valueOf(a) : BigInteger.valueOf(a).add(BigInteger.ZERO.setBit(64)); equalsTester.addEqualityGroup(UnsignedLong.fromLongBits(a), UnsignedLong.valueOf(big), UnsignedLong.valueOf(big.toString()), UnsignedLong.valueOf(big.toString(16), 16)); } equalsTester.testEquals(); }