RollUpBitMask { public static byte[] byteValueFromTagList(final String allTags, final String rolledUpTags) { return fromRolledupTagList(allTags, rolledUpTags).asBytes(); } 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 testByteValueFromTagList() { final String allTags = "tag2,tag4,tag1,tag3"; final String rolledUpTags = "tag3,tag1"; final byte[] maskVal = RollUpBitMask.byteValueFromTagList(allTags, rolledUpTags); final byte[] expectedMaskVal = RollUpBitMask.fromTagPositions(Arrays.asList(0, 2)).asBytes(); assertThat(Arrays.equals(expectedMaskVal, maskVal)).isTrue(); }
@Test void testByteValueFromTagList_missingTag() { assertThatThrownBy(() -> { final String allTags = "tag2,tag4,tag1,tag3"; final String rolledUpTags = "tag3,tagBad"; final byte[] maskVal = RollUpBitMask.byteValueFromTagList(allTags, rolledUpTags); }).isInstanceOf(RuntimeException.class); }