/** Given a base componentId, create a derived (different) one. * This is deterministically done based on baseComponentId and index. * The label is just for display purposes. */ public static ComponentId alloc(String label, UUID coordinatorBase, int index) { byte[] bytes = Bytes.intToBytes(index) ; return new ComponentId(label, coordinatorBase, bytes) ; }
/** Given a base componentId, create a derived (different) one. * This is deterministically done based on baseComponentId and index. * The label is just for display purposes. */ public static ComponentId alloc(String label, UUID coordinatorBase, int index) { byte[] bytes = Bytes.intToBytes(index) ; return new ComponentId(label, coordinatorBase, bytes) ; }
@Test public void intToBytes1() { byte[] b = Bytes.intToBytes(0xF1020304) ; assertEquals(Integer.BYTES, b.length) ; assertEquals(0xF1, b[0]&0xFF) ; assertEquals(0x02, b[1]) ; assertEquals(0x03, b[2]) ; assertEquals(0x04, b[3]) ; }