BitmaskUtils { public static byte[] generateCompositeBitmask(final SortedSet<Integer> fieldPositions) { final byte[] retVal = new byte[(fieldPositions.last() / 8) + 1]; for (final Integer fieldPosition : fieldPositions) { final int bytePosition = fieldPosition / 8; final int bitPosition = fieldPosition % 8; retVal[bytePosition] |= (1 << bitPosition); } return retVal; }  static byte[] generateANDBitmask(final byte[] bitmask1, final byte[] bitmask2); static boolean isAnyBitSet(final byte[] array); static byte[] generateCompositeBitmask(final SortedSet<Integer> fieldPositions); static byte[] generateCompositeBitmask(final Integer fieldPosition); static List<Integer> getFieldPositions(final byte[] bitmask); static int getLowestFieldPosition(final byte[] bitmask); static byte[] generateFieldSubsetBitmask(
      final CommonIndexModel indexModel,
      final String[] fieldNames,
      final DataTypeAdapter<?> adapterAssociatedWithFieldIds); static byte[] constructNewValue(
      final byte[] value,
      final byte[] originalBitmask,
      final byte[] newBitmask);  }
@Test public void testGenerateBitSet() { Assert.assertTrue( Arrays.equals(zeroth.toByteArray(), BitmaskUtils.generateCompositeBitmask(0))); Assert.assertTrue( Arrays.equals(eighth.toByteArray(), BitmaskUtils.generateCompositeBitmask(8))); }
@Test public void testCompositeBitmask() { final byte[] bitmask = BitmaskUtils.generateCompositeBitmask(new TreeSet<>(Arrays.asList(0, 1, 2))); Assert.assertTrue(BitSet.valueOf(bitmask).equals(composite_0_1_2)); }