DayClustering { @Override public String toString() { if (Arrays.equals(groups, TD7_IDX)) { return "TD7"; } if (Arrays.equals(groups, TD2_IDX)) { return "TD2"; } if (Arrays.equals(groups, TD3_IDX)) { return "TD3"; } if (Arrays.equals(groups, TD3C_IDX)) { return "TD3c"; } if (Arrays.equals(groups, TD4_IDX)) { return "TD4"; } StringBuilder builder = new StringBuilder(); int ng = getGroupsCount(); for (int i = 0; i < ng; ++i) { builder.append('{').append(toString(i)).append('}'); } return builder.toString(); } DayClustering(final int[] groups); static DayClustering create(int[] groups); int getGroup(java.time.DayOfWeek dw); int getGroupsCount(); int getGroupCount(int idx); java.time.DayOfWeek[] group(int idx); int[] positions(int idx); int[][] allPositions(); boolean isInside(DayClustering dc); @Override String toString(); String toString(int i); int[] getGroupsDefinition(); static final DayClustering TD2; }
@Test public void testToString() { DayClustering cl0 = DayClustering.create(new int[]{1,1,1,1,1,0,0}); DayClustering cl1 = DayClustering.create(new int[]{1,1,1,1,1,2,0}); DayClustering cl2 = DayClustering.create(new int[]{1,2,3,4,5,6,0}); assertTrue(cl0.toString().equalsIgnoreCase("td2")); assertTrue(cl1.toString().equalsIgnoreCase("td3")); assertTrue(cl2.toString().equalsIgnoreCase("td7")); }