### Question:
Range implements WritableComparable<Range> { @Override public void readFields(DataInput in) throws IOException { infiniteStartKey = in.readBoolean(); infiniteStopKey = in.readBoolean(); if (infiniteStartKey) { start = null; } else { start = new Key(); start.readFields(in); } if (infiniteStopKey) { stop = null; } else { stop = new Key(); stop.readFields(in); } startKeyInclusive = in.readBoolean(); stopKeyInclusive = in.readBoolean(); if (!infiniteStartKey && !infiniteStopKey && beforeStartKey(stop)) { throw new InvalidObjectException( "Start key must be less than end key in range (" + start + ", " + stop + ")"); } } Range();  Range(Key startKey, Key endKey);  Range(CharSequence row);  Range(Text row);  Range(Text startRow, Text endRow);  Range(CharSequence startRow, CharSequence endRow);  Range(Text startRow, boolean startRowInclusive, Text endRow, boolean endRowInclusive);  Range(CharSequence startRow, boolean startRowInclusive, CharSequence endRow,
      boolean endRowInclusive);  Range(Key startKey, boolean startKeyInclusive, Key endKey, boolean endKeyInclusive);  Range(Range range);  Range(Key start, Key stop, boolean startKeyInclusive, boolean stopKeyInclusive,
      boolean infiniteStartKey, boolean infiniteStopKey); protected  Range(Key start, boolean startKeyInclusive, boolean infiniteStartKey, Key stop,
      boolean stopKeyInclusive, boolean infiniteStopKey);  Range(TRange trange); Key getStartKey(); boolean beforeStartKey(Key key); Key getEndKey(); boolean afterEndKey(Key key); @Override int hashCode(); @Override boolean equals(Object o); boolean equals(Range otherRange); @Override int compareTo(Range o); boolean contains(Key key); static List<Range> mergeOverlapping(Collection<Range> ranges); Range clip(Range range); Range clip(Range range, boolean returnNullIfDisjoint); Range bound(Column min, Column max); @Override String toString(); @Override void readFields(DataInput in); @Override void write(DataOutput out); boolean isStartKeyInclusive(); boolean isEndKeyInclusive(); TRange toThrift(); boolean isInfiniteStartKey(); boolean isInfiniteStopKey(); static Range exact(Text row); static Range exact(Text row, Text cf); static Range exact(Text row, Text cf, Text cq); static Range exact(Text row, Text cf, Text cq, Text cv); static Range exact(Text row, Text cf, Text cq, Text cv, long ts); static Text followingPrefix(Text prefix); static Range prefix(Text rowPrefix); static Range prefix(Text row, Text cfPrefix); static Range prefix(Text row, Text cf, Text cqPrefix); static Range prefix(Text row, Text cf, Text cq, Text cvPrefix); static Range exact(CharSequence row); static Range exact(CharSequence row, CharSequence cf); static Range exact(CharSequence row, CharSequence cf, CharSequence cq); static Range exact(CharSequence row, CharSequence cf, CharSequence cq, CharSequence cv); static Range exact(CharSequence row, CharSequence cf, CharSequence cq, CharSequence cv,
      long ts); static Range prefix(CharSequence rowPrefix); static Range prefix(CharSequence row, CharSequence cfPrefix); static Range prefix(CharSequence row, CharSequence cf, CharSequence cqPrefix); static Range prefix(CharSequence row, CharSequence cf, CharSequence cq,
      CharSequence cvPrefix);  }### Answer:
@Test public void testReadFields() throws Exception { Range r = newRange("nuts", "soup"); ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream dos = new DataOutputStream(baos); r.write(dos); dos.close(); ByteArrayInputStream bais = new ByteArrayInputStream(baos.toByteArray()); DataInputStream dis = new DataInputStream(bais); Range r2 = new Range(); r2.readFields(dis); dis.close(); assertEquals(r, r2); }