@Test public void compare() throws Exception { WritableRawComparableUnion a = new WritableRawComparableUnion( new IntOption(100), new LongOption(200L)); WritableRawComparableUnion b = new WritableRawComparableUnion( new IntOption(101), new LongOption(201L)); WritableRawComparableUnion c = new WritableRawComparableUnion( new IntOption(100), new LongOption(200L)); a.switchObject(0); b.switchObject(0); c.switchObject(0); assertThat(cmp(a, b), is(lessThan(0))); assertThat(cmp(b, c), is(greaterThan(0))); assertThat(cmp(c, a), is(equalTo(0))); a.switchObject(1); b.switchObject(1); c.switchObject(1); assertThat(cmp(a, b), is(lessThan(0))); assertThat(cmp(b, c), is(greaterThan(0))); assertThat(cmp(c, a), is(equalTo(0))); a.switchObject(0); c.switchObject(1); assertThat(cmp(a, c), is(not(0))); assertThat(cmp(c, a), is(not(0))); }
@Override public Object switchObject(int newPosition) { this.position = newPosition; return getObject(); }
WritableRawComparableUnion implements Union, WritableRawComparable { @Override public Object switchObject(int newPosition) { this.position = newPosition; return getObject(); } }
WritableRawComparableUnion implements Union, WritableRawComparable { @Override public Object switchObject(int newPosition) { this.position = newPosition; return getObject(); } WritableRawComparableUnion(Class<?>... classes);  WritableRawComparableUnion(WritableRawComparable... objects); }
WritableRawComparableUnion implements Union, WritableRawComparable { @Override public Object switchObject(int newPosition) { this.position = newPosition; return getObject(); } WritableRawComparableUnion(Class<?>... classes);  WritableRawComparableUnion(WritableRawComparable... objects); @Override final int getPosition(); @Override Object switchObject(int newPosition); @Override final Object getObject(); @Override void write(DataOutput out); @Override void readFields(DataInput in); @Override int compareTo(WritableRawComparable o); @Override int getSizeInBytes(byte[] buf, int offset); @Override int compareInBytes(byte[] b1, int o1, byte[] b2, int o2); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString(); }
WritableRawComparableUnion implements Union, WritableRawComparable { @Override public Object switchObject(int newPosition) { this.position = newPosition; return getObject(); } WritableRawComparableUnion(Class<?>... classes);  WritableRawComparableUnion(WritableRawComparable... objects); @Override final int getPosition(); @Override Object switchObject(int newPosition); @Override final Object getObject(); @Override void write(DataOutput out); @Override void readFields(DataInput in); @Override int compareTo(WritableRawComparable o); @Override int getSizeInBytes(byte[] buf, int offset); @Override int compareInBytes(byte[] b1, int o1, byte[] b2, int o2); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }