@Test public void testRelatedItemIds() { RelatedItemInfo info1 = createRelatedItemInfoObj("1"); RelatedItemInfo info2 = createRelatedItemInfoObj("2"); RelatedItemInfo info3 = createRelatedItemInfoObj("3"); RelatedItemInfo info4 = createRelatedItemInfoObj("4"); RelatedItemInfo info5 = createRelatedItemInfoObj("5"); RelatedItemInfo[][] relatedItemIds = BasicRelatedItemIndexingMessageConverter.relatedIds(new RelatedItemInfo[]{info1, info2, info3, info4, info5}, 5); String[] concatIds = new String[relatedItemIds.length]; for(int i = 0;i<relatedItemIds.length;i++) { StringBuilder b = new StringBuilder(5); for(int j=0;j<relatedItemIds[i].length;j++) { b.append(relatedItemIds[i][j].getId().toString()); } concatIds[i] = b.toString(); } System.out.println(Arrays.toString(concatIds)); assertSame(info5, relatedItemIds[0][4]); assertSame(info1, relatedItemIds[1][4]); assertSame(info2, relatedItemIds[2][4]); assertSame(info3, relatedItemIds[3][4]); assertSame(info4, relatedItemIds[4][4]); assertEquals("12345",concatIds[0]); assertEquals("23451",concatIds[1]); assertEquals("34512",concatIds[2]); assertEquals("45123",concatIds[3]); assertEquals("51234",concatIds[4]); }
public static RelatedItemInfo[][] relatedIds(RelatedItemInfo[] ids, int length) { int len = length; RelatedItemInfo[][] idSets = new RelatedItemInfo[len][len]; for(int j = 0;j<len;j++) { idSets[0][j] = ids[j]; } for(int i=1;i<len;i++) { int k=0; for(int j=i;j<len;j++) { idSets[i][k++] = ids[j]; } for(int j=0;j<i;j++) { idSets[i][k++] = ids[j]; } } return idSets; }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public static RelatedItemInfo[][] relatedIds(RelatedItemInfo[] ids, int length) { int len = length; RelatedItemInfo[][] idSets = new RelatedItemInfo[len][len]; for(int j = 0;j<len;j++) { idSets[0][j] = ids[j]; } for(int i=1;i<len;i++) { int k=0; for(int j=i;j<len;j++) { idSets[i][k++] = ids[j]; } for(int j=0;j<i;j++) { idSets[i][k++] = ids[j]; } } return idSets; } }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public static RelatedItemInfo[][] relatedIds(RelatedItemInfo[] ids, int length) { int len = length; RelatedItemInfo[][] idSets = new RelatedItemInfo[len][len]; for(int j = 0;j<len;j++) { idSets[0][j] = ids[j]; } for(int i=1;i<len;i++) { int k=0; for(int j=i;j<len;j++) { idSets[i][k++] = ids[j]; } for(int j=0;j<i;j++) { idSets[i][k++] = ids[j]; } } return idSets; } BasicRelatedItemIndexingMessageConverter(Configuration configuration); }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public static RelatedItemInfo[][] relatedIds(RelatedItemInfo[] ids, int length) { int len = length; RelatedItemInfo[][] idSets = new RelatedItemInfo[len][len]; for(int j = 0;j<len;j++) { idSets[0][j] = ids[j]; } for(int i=1;i<len;i++) { int k=0; for(int j=i;j<len;j++) { idSets[i][k++] = ids[j]; } for(int j=0;j<i;j++) { idSets[i][k++] = ids[j]; } } return idSets; } BasicRelatedItemIndexingMessageConverter(Configuration configuration); RelatedItem[] convertFrom(RelatedItemIndexingMessage message); static RelatedItemInfo[][] relatedIds(RelatedItemInfo[] ids, int length); }
BasicRelatedItemIndexingMessageConverter implements RelatedItemIndexingMessageConverter { public static RelatedItemInfo[][] relatedIds(RelatedItemInfo[] ids, int length) { int len = length; RelatedItemInfo[][] idSets = new RelatedItemInfo[len][len]; for(int j = 0;j<len;j++) { idSets[0][j] = ids[j]; } for(int i=1;i<len;i++) { int k=0; for(int j=i;j<len;j++) { idSets[i][k++] = ids[j]; } for(int j=0;j<i;j++) { idSets[i][k++] = ids[j]; } } return idSets; } BasicRelatedItemIndexingMessageConverter(Configuration configuration); RelatedItem[] convertFrom(RelatedItemIndexingMessage message); static RelatedItemInfo[][] relatedIds(RelatedItemInfo[] ids, int length);  }