@Test public void compareTo() { FloatOption a = new FloatOption(); FloatOption b = new FloatOption(); FloatOption c = new FloatOption(); FloatOption d = new FloatOption(); FloatOption e = new FloatOption(); a.modify(-10); b.modify(0); c.modify(30); d.modify(-10); e.modify(-30); assertThat(compare(a, b), lessThan(0)); assertThat(compare(b, c), lessThan(0)); assertThat(compare(c, a), greaterThan(0)); assertThat(compare(a, c), lessThan(0)); assertThat(compare(b, a), greaterThan(0)); assertThat(compare(c, b), greaterThan(0)); assertThat(compare(a, d), is(0)); assertThat(compare(d, e), greaterThan(0)); }
@Override public int compareTo(WritableRawComparable o) { FloatOption other = (FloatOption) o; if (nullValue | other.nullValue) { if (nullValue & other.nullValue) { return 0; } return nullValue ? -1 : +1; } int left = encode(value) - Integer.MIN_VALUE; int right = encode(other.value) - Integer.MIN_VALUE; if (left == right) { return 0; } if (left < right) { return -1; } return +1; }
FloatOption extends ValueOption<FloatOption> { @Override public int compareTo(WritableRawComparable o) { FloatOption other = (FloatOption) o; if (nullValue | other.nullValue) { if (nullValue & other.nullValue) { return 0; } return nullValue ? -1 : +1; } int left = encode(value) - Integer.MIN_VALUE; int right = encode(other.value) - Integer.MIN_VALUE; if (left == right) { return 0; } if (left < right) { return -1; } return +1; } }
FloatOption extends ValueOption<FloatOption> { @Override public int compareTo(WritableRawComparable o) { FloatOption other = (FloatOption) o; if (nullValue | other.nullValue) { if (nullValue & other.nullValue) { return 0; } return nullValue ? -1 : +1; } int left = encode(value) - Integer.MIN_VALUE; int right = encode(other.value) - Integer.MIN_VALUE; if (left == right) { return 0; } if (left < right) { return -1; } return +1; } FloatOption();  FloatOption(float value); }
FloatOption extends ValueOption<FloatOption> { @Override public int compareTo(WritableRawComparable o) { FloatOption other = (FloatOption) o; if (nullValue | other.nullValue) { if (nullValue & other.nullValue) { return 0; } return nullValue ? -1 : +1; } int left = encode(value) - Integer.MIN_VALUE; int right = encode(other.value) - Integer.MIN_VALUE; if (left == right) { return 0; } if (left < right) { return -1; } return +1; } FloatOption();  FloatOption(float value); float get(); float or(float alternate); void add(float delta); void add(FloatOption other); @Deprecated FloatOption modify(float newValue); @Override @Deprecated void copyFrom(FloatOption optionOrNull); @Override int hashCode(); @Override boolean equals(Object obj); boolean has(float other); @Override int compareTo(WritableRawComparable o); @Override String toString(); @Override void write(DataOutput out); @SuppressWarnings("deprecation") @Override void readFields(DataInput in); @SuppressWarnings("deprecation") @Override int restore(byte[] bytes, int offset, int limit); @Override int getSizeInBytes(byte[] buf, int offset); @Override int compareInBytes(byte[] b1, int o1, byte[] b2, int o2); static int getBytesLength(byte[] bytes, int offset, int length); static int compareBytes(
            byte[] b1, int s1, int l1,
            byte[] b2, int s2, int l2); }
FloatOption extends ValueOption<FloatOption> { @Override public int compareTo(WritableRawComparable o) { FloatOption other = (FloatOption) o; if (nullValue | other.nullValue) { if (nullValue & other.nullValue) { return 0; } return nullValue ? -1 : +1; } int left = encode(value) - Integer.MIN_VALUE; int right = encode(other.value) - Integer.MIN_VALUE; if (left == right) { return 0; } if (left < right) { return -1; } return +1; } FloatOption();  FloatOption(float value); float get(); float or(float alternate); void add(float delta); void add(FloatOption other); @Deprecated FloatOption modify(float newValue); @Override @Deprecated void copyFrom(FloatOption optionOrNull); @Override int hashCode(); @Override boolean equals(Object obj); boolean has(float other); @Override int compareTo(WritableRawComparable o); @Override String toString(); @Override void write(DataOutput out); @SuppressWarnings("deprecation") @Override void readFields(DataInput in); @SuppressWarnings("deprecation") @Override int restore(byte[] bytes, int offset, int limit); @Override int getSizeInBytes(byte[] buf, int offset); @Override int compareInBytes(byte[] b1, int o1, byte[] b2, int o2); static int getBytesLength(byte[] bytes, int offset, int length); static int compareBytes(
            byte[] b1, int s1, int l1,
            byte[] b2, int s2, int l2);  }