Yuta HIGUCHI | 1ef85c4 | 2014-01-29 17:23:21 -0800 | [diff] [blame] | 1 | package net.onrc.onos.datastore.utils; |
| 2 | |
| 3 | import java.nio.ByteBuffer; |
| 4 | import java.util.Comparator; |
| 5 | |
| 6 | public final class ByteArrayComparator implements Comparator<byte[]> { |
| 7 | |
| 8 | public static final ByteArrayComparator BYTEARRAY_COMPARATOR = new ByteArrayComparator(); |
| 9 | |
| 10 | @Override |
| 11 | public int compare(byte[] o1, byte[] o2) { |
| 12 | final ByteBuffer b1 = ByteBuffer.wrap(o1); |
| 13 | final ByteBuffer b2 = ByteBuffer.wrap(o2); |
| 14 | return b1.compareTo(b2); |
| 15 | } |
| 16 | } |