@SuppressWarnings("deprecation") @Override public void addLong(long value) { this.target.modify(value); } }
/** * Sets amount_total. * @param value the value */ @SuppressWarnings("deprecation") public void setAmountTotal(long value) { this.amountTotal.modify(value); } /**
/** * Sets selling_price_total. * @param value the value */ @SuppressWarnings("deprecation") public void setSellingPriceTotal(long value) { this.sellingPriceTotal.modify(value); } /**
@SuppressWarnings("deprecation") @Override protected void doParseDefault(CharSequence contents, LongOption property) { property.modify(TextUtil.parseLong(contents, 0, contents.length())); }
@SuppressWarnings("deprecation") @Override protected void set(BigDecimal value, LongOption property) { property.modify(value.longValueExact()); }
@SuppressWarnings("deprecation") @Override public void readFields(DataInput in) throws IOException { if (in.readBoolean()) { modify(in.readLong() + Long.MIN_VALUE); } else { setNull(); } }
@SuppressWarnings("deprecation") @Override void modify(LongOption holder, Object value) { holder.modify(cast(Number.class, value).longValue()); } @Override
@SuppressWarnings("deprecation") @Override protected void doRead(ValueReader reader, LongOption property) throws IOException { long value = reader.readLong(); property.modify(value); }
@SuppressWarnings("deprecation") @Override public void set(ValueOption<?> target, Object value) { if (value == null) { target.setNull(); } else { ((LongOption) target).modify(inspector.get(value)); } } }
@SuppressWarnings("deprecation") @Override public int restore(byte[] bytes, int offset, int limit) throws IOException { if (limit - offset == 0) { throw new IOException(MessageFormat.format( "Cannot restore a long field ({0})", "invalid length")); } if (bytes[offset + 0] == 0) { setNull(); return 1; } else if (limit - offset >= 1 + 1) { modify(ByteArrayUtil.readLong(bytes, offset + 1) + Long.MIN_VALUE); return 8 + 1; } else { throw new IOException(MessageFormat.format( "Cannot restore a long field ({0})", "invalid length")); } }
@SuppressWarnings("deprecation") private void fill0(LongOption option, boolean doRecover) throws CsvFormatException { if (lineBuffer.hasRemaining()) { try { long value = Long.parseLong(lineBuffer.toString()); option.modify(value); } catch (NumberFormatException e) { if (doRecover && trimWhitespaces()) { fill0(option, false); return; } throw new CsvFormatException(createStatusInLine(Reason.INVALID_CELL_FORMAT, "long value"), e); } } else { option.setNull(); } }
/** * test for or w/ present value. */ @Test public void orNotNull() { LongOption option = new LongOption(); option.modify(100); assertThat(option.or(30), is(100L)); }
/** * test for get. */ @Test public void get() { LongOption option = new LongOption(); option.modify(100); assertThat(option.get(), is(100L)); assertThat(option.isNull(), is(false)); }
/** * test for copyFrom w/ null. */ @Test public void copyNull() { LongOption option = new LongOption(); option.modify(100); LongOption other = new LongOption(); option.copyFrom(other); assertThat(option.isNull(), is(true)); option.modify(100); option.copyFrom(null); assertThat(option.isNull(), is(true)); }
/** * test for Writable. */ @Test public void write() { LongOption option = new LongOption(); option.modify(100); LongOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for Writable w/ max. */ @Test public void write_max() { LongOption option = new LongOption(); option.modify(Long.MAX_VALUE); LongOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for Writable w/ min. */ @Test public void write_min() { LongOption option = new LongOption(); option.modify(Long.MIN_VALUE); LongOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for compare w/ null. */ @Test public void compareNull() { LongOption a = new LongOption(); LongOption b = new LongOption(); LongOption c = new LongOption(); a.modify(Long.MIN_VALUE); assertThat(compare(a, b), greaterThan(0)); assertThat(compare(b, a), lessThan(0)); assertThat(compare(b, c), is(0)); }
/** * Creates object from classes. * @throws Exception if failed */ @Test public void createFromClasses() throws Exception { Union union = new WritableUnion(IntOption.class, LongOption.class, StringOption.class); assertThat(union.switchObject(0), instanceOf(IntOption.class)); assertThat(union.switchObject(1), instanceOf(LongOption.class)); assertThat(union.switchObject(2), instanceOf(StringOption.class)); ((IntOption) union.switchObject(0)).modify(100); assertThat(union.getPosition(), is(0)); ((LongOption) union.switchObject(1)).modify(200L); assertThat(union.getPosition(), is(1)); ((StringOption) union.switchObject(2)).modify("Hello, world!"); assertThat(union.getPosition(), is(2)); assertThat(union.switchObject(0), is((Object) new IntOption(100))); assertThat(union.switchObject(1), is((Object) new LongOption(200L))); assertThat(union.switchObject(2), is((Object) new StringOption("Hello, world!"))); }