RollUpBitMask { public List<Boolean> getBooleanMask(final int tagCount) { final String bitMask = Integer.toBinaryString(mask); final List<Boolean> booleanMask = new ArrayList<>(); for (int strPos = bitMask.length() - 1; strPos >= 0; strPos--) { booleanMask.add(bitMask.charAt(strPos) == '1'); } while (booleanMask.size() < tagCount) { booleanMask.add(false); } return booleanMask; } private  RollUpBitMask(final short mask); static RollUpBitMask fromShort(final short maskValue); static RollUpBitMask fromMask(final short[] mask); static RollUpBitMask fromRolledupTagList(final String allTags, final String rolledUpTags); static byte[] byteValueFromTagList(final String allTags, final String rolledUpTags); static int intValueFromTagList(final String allTags, final String rolledUpTags); static RollUpBitMask fromTagPositions(final List<Integer> tagPositions); static RollUpBitMask fromTagPositions(final SortedSet<Integer> tagPositions); static RollUpBitMask fromBytes(final byte[] bytes); static Set<RollUpBitMask> getRollUpBitMasks(final int tagCount); static Set<List<Boolean>> getRollUpPermutationsAsBooleans(final int tagCount); static Set<List<Integer>> getRollUpPermutationsAsPositions(final int tagCount); SortedSet<Integer> getTagPositions(); List<Integer> getTagPositionsAsList(); List<Boolean> getBooleanMask(final int tagCount); boolean isTagPositionRolledUp(final int tagPosition); RollUpBitMask convert(final Map<Integer, Integer> newToOldFieldPositionMap); short asShort(); byte[] asBytes(); String asHexString(); @Override String toString(); @Override int hashCode(); @Override boolean equals(final Object obj); static final short MASK_LENGTH; static final RollUpBitMask ZERO_MASK; static final String ROLL_UP_TAG_VALUE; }
@Test void testGetBooleanMask() { RollUpBitMask mask; List<Integer> posList; posList = Arrays.asList(0, 1, 2, 3, 4); mask = RollUpBitMask.fromTagPositions(posList); assertThat(mask.getBooleanMask(5)).isEqualTo(Arrays.asList(true, true, true, true, true)); posList = Arrays.asList(0, 2, 4); mask = RollUpBitMask.fromTagPositions(posList); assertThat(mask.getBooleanMask(5)).isEqualTo(Arrays.asList(true, false, true, false, true)); posList = Arrays.asList(); mask = RollUpBitMask.fromTagPositions(posList); assertThat(mask.getBooleanMask(5)).isEqualTo(Arrays.asList(false, false, false, false, false)); }