@SuppressWarnings("deprecation") @Override public void addBoolean(boolean value) { this.target.modify(value); } }
@SuppressWarnings("deprecation") @Override protected void doParse(CharSequence contents, BooleanOption property) { if (trueTester.test(contents)) { property.modify(true); } else if (falseTester.test(contents)) { property.modify(false); } else { throw new IllegalArgumentException(contents.toString()); } }
@SuppressWarnings("deprecation") private void restore(byte field) throws IOException { if (field == SERIALIZE_NULL) { setNull(); } else if (field == SERIALIZE_TRUE) { modify(true); } else if (field == SERIALIZE_FALSE) { modify(false); } else { throw new IOException(MessageFormat.format( "Cannot restore a boolean field ({0})", field)); } }
@SuppressWarnings("deprecation") @Override protected void doRead(ValueReader reader, BooleanOption property) throws IOException { boolean value = reader.readBoolean(); property.modify(value); }
@SuppressWarnings("deprecation") @Override void modify(BooleanOption holder, Object value) { holder.modify(cast(Boolean.class, value)); } @Override
@SuppressWarnings("deprecation") @Override public void fill(BooleanOption option) throws CsvFormatException, IOException { seekBuffer(); if (lineBuffer.hasRemaining()) { boolean value = trueFormat.contentEquals(lineBuffer); option.modify(value); } else { option.setNull(); } }
@SuppressWarnings("deprecation") @Override public void set(ValueOption<?> target, Object value) { if (value == null) { target.setNull(); } else { ((BooleanOption) target).modify(inspector.get(value)); } }
@Override public void fill(BooleanOption option) throws RecordFormatException, IOException { checkCellStart(); if (applyNull(option)) { return; } assertHasRest(option, lookAhead); if (lookAhead == BOOLEAN_TRUE) { option.modify(true); } else if (lookAhead == BOOLEAN_FALSE) { option.modify(false); } else { throw new RecordFormatException(MessageFormat.format( "Invalid character {0} for boolean", (char) lookAhead)); } int next = reader.read(); if (isSeparator(next) == false) { throw new RecordFormatException(MessageFormat.format( "Invalid character {0} for boolean", (char) next)); } setLastSeparator(next); fillLookAhead(); }
/** * test for or. */ @Test public void orNotNull() { BooleanOption option = new BooleanOption(); option.modify(true); assertThat(option.or(false), is(true)); }
/** * test for compare. */ @Test public void compareTo() { BooleanOption a = new BooleanOption(); BooleanOption b = new BooleanOption(); BooleanOption c = new BooleanOption(); a.modify(false); b.modify(true); c.modify(false); assertThat(compare(a, b), lessThan(0)); assertThat(compare(b, a), greaterThan(0)); assertThat(compare(a, c), is(0)); }
/** * obtain value. */ @Test public void get() { BooleanOption option = new BooleanOption(); option.modify(false); assertThat(option.get(), is(false)); assertThat(option.isNull(), is(false)); }
/** * test for copyFrom w/ null. */ @Test public void copyNull() { BooleanOption option = new BooleanOption(); option.modify(true); BooleanOption other = new BooleanOption(); option.copyFrom(other); assertThat(option.isNull(), is(true)); option.modify(true); option.copyFrom(null); assertThat(option.isNull(), is(true)); }
/** * test for Writable. */ @Test public void writeFalse() { BooleanOption option = new BooleanOption(); option.modify(true); BooleanOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for Writable. */ @Test public void writeTrue() { BooleanOption option = new BooleanOption(); option.modify(true); BooleanOption restored = restore(option); assertThat(restored.get(), is(option.get())); }
/** * test for compare w/ null. */ @Test public void compareNull() { BooleanOption a = new BooleanOption(); BooleanOption b = new BooleanOption(); BooleanOption c = new BooleanOption(); a.modify(false); assertThat(compare(a, b), greaterThan(0)); assertThat(compare(b, a), lessThan(0)); assertThat(compare(b, c), is(0)); }
BooleanOption value = new BooleanOption(); value.modify(true); emitter.emit(value); value.modify(false); emitter.emit(value); emitter.endRecord(); value.modify(false); emitter.emit(value); value.modify(true); emitter.emit(value); emitter.endRecord(); value.modify(true); emitter.emit(value); emitter.endRecord();