@SuppressWarnings("deprecation") @Override protected void drive(BigDecimal value) { target.modify(value); }
@SuppressWarnings("deprecation") @Override protected void set(BigDecimal value, DecimalOption property) { property.modify(value); }
@SuppressWarnings("deprecation") @Override public void addValueFromDictionary(int dictionaryId) { target.modify(dict[dictionaryId]); } }
@Override @Deprecated public void copyFrom(DecimalOption optionOrNull) { if (this == optionOrNull) { return; } else if (optionOrNull == null || optionOrNull.nullValue) { this.nullValue = true; } else { modify(optionOrNull.entity); } }
@SuppressWarnings("deprecation") @Override protected void doParseDefault(CharSequence contents, DecimalOption property) { property.modify(TextUtil.parseDecimal(contents, 0, contents.length())); }
@SuppressWarnings("deprecation") @Override public void addInt(int value) { target.modify(convert(value)); }
@SuppressWarnings("deprecation") @Override public void addBinary(Binary value) { target.modify(convert(value)); }
@SuppressWarnings("deprecation") @Override protected void doRead(ValueReader reader, DecimalOption property) throws IOException { BigDecimal value = reader.readDecimal(); property.modify(value); }
@SuppressWarnings("deprecation") @Override protected void set(ValueOption<?> target, String value) { try { ((DecimalOption) target).modify(new BigDecimal(value)); } catch (NumberFormatException e) { throw new IllegalArgumentException(MessageFormat.format( Messages.getString("StringValueSerdeFactory.errorInvalidDecimal"), //$NON-NLS-1$ value), e); } } }
@SuppressWarnings("deprecation") @Override public void addLong(long value) { target.modify(convert(value)); }
@SuppressWarnings("deprecation") @Override void modify(DecimalOption holder, Object value) { holder.modify(cast(BigDecimal.class, value)); } @Override
@SuppressWarnings("deprecation") @Override public void set(ValueOption<?> target, Object value) { if (value == null) { target.setNull(); } else if (primitive) { HiveDecimal entity = inspector.getPrimitiveJavaObject(value); ((DecimalOption) target).modify(entity.bigDecimalValue()); } else { HiveDecimalWritable writable = inspector.getPrimitiveWritableObject(value); ((DecimalOption) target).modify(writable.getHiveDecimal().bigDecimalValue()); } }
@Override public void fill(DecimalOption option) throws RecordFormatException, IOException { checkCellStart(); if (applyNull(option)) { return; } assertHasRest(option, lookAhead); charBuffer[0] = (char) lookAhead; int length = readString(1, option); option.modify(new BigDecimal(charBuffer, 0, length + 1)); fillLookAhead(); }
/** * test for copyFrom. */ @Test public void copy() { DecimalOption option = new DecimalOption(); DecimalOption other = new DecimalOption(); other.modify(decimal(50)); option.copyFrom(other); assertThat(option.get(), is(decimal(50))); option.modify(decimal(0)); assertThat(other.get(), is(decimal(50))); }
/** * test for get. */ @Test public void get() { DecimalOption option = new DecimalOption(); option.modify(decimal(100)); assertThat(option.get(), is(decimal(100))); assertThat(option.isNull(), is(false)); }
/** * test for Writable w/ min. */ @Test public void write_min() { DecimalOption option = new DecimalOption(); option.modify(decimal(Long.MIN_VALUE).add(decimal(Long.MAX_VALUE))); DecimalOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for Writable w/ max. */ @Test public void write_max() { DecimalOption option = new DecimalOption(); option.modify(decimal(Long.MAX_VALUE).add(decimal(Long.MAX_VALUE))); DecimalOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for Writable. */ @Test public void write() { DecimalOption option = new DecimalOption(); option.modify(decimal("3.14")); DecimalOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for or w/ present value. */ @Test public void orNotNull() { DecimalOption option = new DecimalOption(); option.modify(decimal(100)); assertThat(option.or(decimal(30)), is(decimal(100))); }
/** * test for compare w/ null. */ @Test public void compareNull() { DecimalOption a = new DecimalOption(); DecimalOption b = new DecimalOption(); DecimalOption c = new DecimalOption(); a.modify(decimal(Long.MIN_VALUE)); assertThat(compare(a, b), greaterThan(0)); assertThat(compare(b, a), lessThan(0)); assertThat(compare(b, c), is(0)); }