/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed as * an unsigned {@code int} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed as * an unsigned {@code int} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed as * an unsigned {@code int} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string) { return valueOf(string, 10); }
@Value.Derived public UnsignedInteger der() { return UnsignedInteger.valueOf(1); } }
@GwtIncompatible // too slow public void testEquals() { EqualsTester equalsTester = new EqualsTester(); for (int a : TEST_INTS) { long value = a & 0xffffffffL; equalsTester.addEqualityGroup( UnsignedInteger.fromIntBits(a), UnsignedInteger.valueOf(value), UnsignedInteger.valueOf(Long.toString(value)), UnsignedInteger.valueOf(Long.toString(value, 16), 16)); } equalsTester.testEquals(); }
public void testValueOfBigInteger() { long min = 0; long max = (1L << 32) - 1; for (long value : TEST_LONGS) { boolean expectSuccess = value >= min && value <= max; try { assertEquals(value, UnsignedInteger.valueOf(BigInteger.valueOf(value)).longValue()); assertTrue(expectSuccess); } catch (IllegalArgumentException e) { assertFalse(expectSuccess); } } }
/** * Throws an exception if the UnsignedInteger is greater than a given int, returning the int value otherwise * * @param unsignedInteger the number * @param max the maximum value * @param errorMessage error message (can be Java format string) * @param args args for error message format string * @return the value * @throws IOException if the value is greater than max */ public static int intValueMax(UnsignedInteger unsignedInteger, int max, String errorMessage, Object... args) throws IOException { if (unsignedInteger.compareTo(UnsignedInteger.valueOf(max)) > 0) { throw createException(errorMessage, args, "< " + max, unsignedInteger); } return unsignedInteger.intValue(); }
public void testValueOfLong() { long min = 0; long max = (1L << 32) - 1; for (long value : TEST_LONGS) { boolean expectSuccess = value >= min && value <= max; try { assertEquals(value, UnsignedInteger.valueOf(value).longValue()); assertTrue(expectSuccess); } catch (IllegalArgumentException e) { assertFalse(expectSuccess); } } }
throw new IOException("Invalid checksum " + this); if (lastRecordOffset.compareTo(UnsignedInteger.valueOf(Integer.MAX_VALUE)) > 0) { throw new IOException("Last record offset too big to fit into signed integer");
/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed * as an unsigned {@code int} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed * as an unsigned {@code int} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed * as an unsigned {@code int} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed * as an unsigned {@code int} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed * as an unsigned {@code int} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed * as an unsigned {@code int} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed * as an unsigned {@code int} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string) { return valueOf(string, 10); }
/** * Returns an {@code UnsignedInteger} holding the value of the specified {@code String}, parsed * as an unsigned {@code int} value. * * @throws NumberFormatException if the string does not contain a parsable unsigned {@code int} * value */ public static UnsignedInteger valueOf(String string) { return valueOf(string, 10); }
private void emitPositionNode(final @Nullable Long position) { if (position != null) { super.writer.startPositionNode(UnsignedInteger.valueOf(position)); super.writer.endNode(); } }
@GwtIncompatible // too slow public void testEquals() { EqualsTester equalsTester = new EqualsTester(); for (int a : TEST_INTS) { long value = a & 0xffffffffL; equalsTester.addEqualityGroup(UnsignedInteger.fromIntBits(a), UnsignedInteger.valueOf(value), UnsignedInteger.valueOf(Long.toString(value)), UnsignedInteger.valueOf(Long.toString(value, 16), 16)); } equalsTester.testEquals(); }
@Override public BsonValue visit(DateTimeValue value, Void arg) { Instant instant = value.getValue().toInstant(ZoneOffset.UTC); return new BsonTimestamp( UnsignedInteger.valueOf(instant.getEpochSecond()).intValue(), instant.getNano() ); }