ItemIdComposer { public static long extractWrappedIdPart(long composedId) { if (composedId == RecyclerView.NO_ID) { return RecyclerView.NO_ID; } return (composedId << (64 - BIT_WIDTH_GROUP_ID - BIT_WIDTH_CHILD_ID - BIT_OFFSET_CHILD_ID)) >> (64 - (BIT_WIDTH_GROUP_ID + BIT_WIDTH_CHILD_ID)); } private  ItemIdComposer(); static long composeExpandableChildId(@IntRange(from = MIN_GROUP_ID, to = MAX_GROUP_ID) long groupId, @IntRange(from = MIN_CHILD_ID, to = MAX_CHILD_ID) long childId); static long composeExpandableGroupId(@IntRange(from = MIN_GROUP_ID, to = MAX_GROUP_ID) long groupId); static boolean isExpandableGroup(long composedId); @IntRange(from = MIN_SEGMENT, to = MAX_SEGMENT) static int extractSegmentPart(long composedId); @IntRange(from = MIN_GROUP_ID, to = MAX_GROUP_ID) static long extractExpandableGroupIdPart(long composedId); @IntRange(from = MIN_CHILD_ID, to = MAX_CHILD_ID) static long extractExpandableChildIdPart(long composedId); static long extractWrappedIdPart(long composedId); static long composeSegment(@IntRange(from = MIN_SEGMENT, to = MAX_SEGMENT) int segment, long wrappedId); static final int BIT_OFFSET_RESERVED_SIGN_FLAG; static final int BIT_OFFSET_SEGMENT; static final int BIT_OFFSET_GROUP_ID; static final int BIT_OFFSET_CHILD_ID; static final int BIT_WIDTH_RESERVED_SIGN_FLAG; static final int BIT_WIDTH_SEGMENT; static final int BIT_WIDTH_GROUP_ID; static final int BIT_WIDTH_CHILD_ID; static final long BIT_MASK_RESERVED_SIGN_FLAG; static final long BIT_MASK_SEGMENT; static final long BIT_MASK_GROUP_ID; static final long BIT_MASK_CHILD_ID; static final int MIN_SEGMENT; static final int MAX_SEGMENT; static final long MIN_GROUP_ID; static final long MAX_GROUP_ID; static final long MIN_CHILD_ID; static final long MAX_CHILD_ID; static final long MIN_WRAPPED_ID; static final long MAX_WRAPPED_ID; }
@Test public void extractWrappedIdPart() throws Exception { assertThat(ItemIdComposer.extractWrappedIdPart(RecyclerView.NO_ID), is(RecyclerView.NO_ID)); assertThat(ItemIdComposer.extractWrappedIdPart(0L), is(0L)); assertThat(ItemIdComposer.extractWrappedIdPart(ItemIdComposer.BIT_MASK_GROUP_ID | ItemIdComposer.BIT_MASK_CHILD_ID), is(-1L)); assertThat(ItemIdComposer.extractWrappedIdPart(ItemIdComposer.BIT_MASK_RESERVED_SIGN_FLAG), is(0L)); assertThat(ItemIdComposer.extractWrappedIdPart(ItemIdComposer.BIT_MASK_SEGMENT), is(0L)); }