@Override Object extract(DoubleOption holder) { return holder.get(); } });
@Override public double get(Object o) { return ((DoubleOption) o).get(); } }
@Override protected Number get(DoubleOption property) { return property.get(); }
@Override protected void doEmitDefault(DoubleOption property, StringBuilder output) { output.append(property.get()); }
@Override public void write(Object value, RecordConsumer consumer) { consumer.addDouble(((DoubleOption) value).get()); } },
@Override public Object getPrimitiveJavaObject(Object o) { DoubleOption object = (DoubleOption) o; if (object == null || object.isNull()) { return null; } return object.get(); }
@Override protected void doWrite(DoubleOption property, ValueWriter writer) throws IOException { writer.writeDouble(property.get()); }
@Override public void emit(DoubleOption option) throws IOException { startCell(); if (emitNull(option)) { return; } lineBuffer.append(option.get()); }
@Override public Object getPrimitiveWritableObject(Object o) { DoubleOption object = (DoubleOption) o; if (object == null || object.isNull()) { return null; } return new DoubleWritable(object.get()); }
/** * test for get. */ @Test public void get() { DoubleOption option = new DoubleOption(); option.modify(100); assertThat(option.get(), is(100.d)); assertThat(option.isNull(), is(false)); }
assertThat(option.get(), is((double) 0)); assertThat(option.get(), is((double) 1)); assertThat(option.get(), is((double) 50)); assertThat(option.get(), is((double) -1)); assertThat(option.get(), is((double) -50)); assertThat(option.get(), is(0.5)); assertThat(option.get(), is(-0.5)); assertThat(option.get(), is(100.)); assertThat(option.get(), is(-100.)); assertThat(option.get(), is((double) 0)); assertThat(option.get(), is((double) 0));
/** * test for parsing {@code float} value. * @throws Exception if failed */ @Test public void fillDouble() throws Exception { DoubleOption value = new DoubleOption(); create("float"); assertThat(parser.next(), is(true)); parser.fill(value); assertThat(value.get(), is(+0.d)); parser.fill(value); assertThat(value.get(), is(-0.d)); parser.fill(value); assertThat(value.get(), is(+10.5d)); parser.fill(value); assertThat(value.get(), is(-10.5d)); parser.endRecord(); assertThat(parser.next(), is(true)); parser.fill(value); assertThat(value.isNull(), is(true)); parser.fill(value); assertThat(value.get(), is(Double.POSITIVE_INFINITY)); parser.fill(value); assertThat(value.get(), is(Double.NEGATIVE_INFINITY)); parser.fill(value); assertThat(value.get(), is(Double.NaN)); parser.endRecord(); assertThat(parser.next(), is(false)); }
assertThat(parser.next(), is(true)); parser.fill(value); assertThat(value.get(), is(+0.d)); parser.fill(value); assertThat(value.get(), is(-0.d)); parser.fill(value); assertThat(value.get(), is(+10.5d)); parser.fill(value); assertThat(value.get(), is(-10.5d)); assertThat(value.isNull(), is(true)); parser.fill(value); assertThat(value.get(), is(Double.POSITIVE_INFINITY)); parser.fill(value); assertThat(value.get(), is(Double.NEGATIVE_INFINITY)); parser.fill(value); assertThat(value.get(), is(Double.NaN));