PactRecord implements Value { public void clear() { if (this.numFields > 0) { this.numFields = 0; this.firstModifiedPos = 0; } } PactRecord();  PactRecord(Value value);  PactRecord(Value val1, Value val2);  PactRecord(int numFields); int getNumFields(); void setNumFields(final int numFields); void makeSpace(int numFields); @SuppressWarnings("unchecked") T getField(final int fieldNum, final Class<T> type); @SuppressWarnings("unchecked") T getField(int fieldNum, T target); boolean getFieldInto(int fieldNum, Value target); boolean getFieldsInto(int[] positions, Value[] targets); void getFieldsIntoCheckingNull(int[] positions, Value[] targets); void setField(int fieldNum, Value value); void addField(Value value); final boolean isNull(int fieldNum); void setNull(int field); void setNull(long mask); void setNull(long[] mask); void clear(); void concatenate(PactRecord record); void unionFields(PactRecord other); void copyToIfModified(PactRecord target); void copyTo(PactRecord target); PactRecord createCopy(); final boolean equalsFields(int[] positions, Value[] searchValues, Value[] deserializationHolders); void updateBinaryRepresenation(); @Override void write(DataOutput out); @Override void read(DataInput in); long serialize(DataOutputView target); void deserialize(DataInputView source);  }
@Test public void testClear() throws IOException { try { PactRecord record = new PactRecord(new PactInteger(42)); record.write(out); Assert.assertEquals(42, record.getField(0, PactInteger.class).getValue()); record.setField(0, new PactInteger(23)); record.write(out); Assert.assertEquals(23, record.getField(0, PactInteger.class).getValue()); record.clear(); Assert.assertEquals(0, record.getNumFields()); PactRecord record2 = new PactRecord(new PactInteger(42)); record2.read(in); Assert.assertEquals(42, record2.getField(0, PactInteger.class).getValue()); record2.read(in); Assert.assertEquals(23, record2.getField(0, PactInteger.class).getValue()); } catch (Throwable t) { Assert.fail("Test failed due to an exception: " + t.getMessage()); } }