ByteFieldComparatorImpl extends AbstractFieldComparator<ENTITY> implements ByteFieldComparator<ENTITY, D> { @Override public int compare(ENTITY first, ENTITY second) { requireNonNulls(first, second); final byte a = field.getAsByte(first); final byte b = field.getAsByte(second); return applyReversed(Byte.compare(a, b)); } ByteFieldComparatorImpl(HasByteValue<ENTITY, D> field);   ByteFieldComparatorImpl(HasByteValue<ENTITY, D> field, boolean reversed); @Override HasByteValue<ENTITY, D> getField(); @Override NullOrder getNullOrder(); @Override boolean isReversed(); @Override ByteFieldComparatorImpl<ENTITY, D> reversed(); @Override int compare(ENTITY first, ENTITY second); @Override int hashCode(); @Override boolean equals(Object obj); @Override String toString();  }
@Test void testCompareSimple() { final ByteValue first = ByteValue.of((byte) 0); final ByteValue second = ByteValue.of((byte) 1); int expResult = -1; int result = instance.compare(first, second); assertEquals(expResult, result); }
@Test void testCompareAllTheThings() { IntStream.rangeClosed(Byte.MIN_VALUE, Byte.MAX_VALUE).forEach(first -> { IntStream.rangeClosed(Byte.MIN_VALUE, Byte.MAX_VALUE).forEach(second -> { final ByteValue firstByteValue = ByteValue.of((byte) first); final ByteValue secondByteValue = ByteValue.of((byte) second); final int expResult = signum(Byte.compare(firstByteValue.getByte(), secondByteValue.getByte())); final int result = signum(instance.compare(firstByteValue, secondByteValue)); assertEquals(expResult, result); }); }); }