@Test public void testToString() { assertThat(Priority.getDefault().toString(), equalTo("default priority")); assertThat(Priority.getDefault().next().toString(), equalTo("default priority + 1")); assertThat(Priority.getDefault().next().next().toString(), equalTo("default priority + 2")); assertThat(Priority.create(1).toString(), equalTo("priority [1]")); assertThat(Priority.create(1).next().toString(), equalTo("priority [1] + 1")); assertThat(Priority.create(1).next().next().toString(), equalTo("priority [1] + 2")); assertThat(Priority.create(1, 2).toString(), equalTo("priority [1, 2]")); assertThat(Priority.create(1, 2).next().toString(), equalTo("priority [1, 2] + 1")); assertThat(Priority.create(1, 2).next().next().toString(), equalTo("priority [1, 2] + 2")); }
@Override public String toString() { StringBuilder builder = new StringBuilder(); if (weights.length == 0) { builder.append("default priority"); } else { builder.append("priority ["); for (int i = 0; i < weights.length; ++i) { if (i != 0) { builder.append(", "); } builder.append(weights[i]); } builder.append("]"); } if (seq != 0) { builder.append(" + ") .append(seq); } return builder.toString(); }
Priority implements Comparable<Priority> { @Override public String toString() { StringBuilder builder = new StringBuilder(); if (weights.length == 0) { builder.append("default priority"); } else { builder.append("priority ["); for (int i = 0; i < weights.length; ++i) { if (i != 0) { builder.append(", "); } builder.append(weights[i]); } builder.append("]"); } if (seq != 0) { builder.append(" + ") .append(seq); } return builder.toString(); } }
Priority implements Comparable<Priority> { @Override public String toString() { StringBuilder builder = new StringBuilder(); if (weights.length == 0) { builder.append("default priority"); } else { builder.append("priority ["); for (int i = 0; i < weights.length; ++i) { if (i != 0) { builder.append(", "); } builder.append(weights[i]); } builder.append("]"); } if (seq != 0) { builder.append(" + ") .append(seq); } return builder.toString(); } private  Priority(int[] weights, int seq); }
Priority implements Comparable<Priority> { @Override public String toString() { StringBuilder builder = new StringBuilder(); if (weights.length == 0) { builder.append("default priority"); } else { builder.append("priority ["); for (int i = 0; i < weights.length; ++i) { if (i != 0) { builder.append(", "); } builder.append(weights[i]); } builder.append("]"); } if (seq != 0) { builder.append(" + ") .append(seq); } return builder.toString(); } private  Priority(int[] weights, int seq); static Priority getDefault(); static Priority create(int weight, int... weights); boolean isDefault(); Priority next(); @Override boolean equals(Object obj); @Override int hashCode(); @Override int compareTo(Priority o); @Override String toString(); }
Priority implements Comparable<Priority> { @Override public String toString() { StringBuilder builder = new StringBuilder(); if (weights.length == 0) { builder.append("default priority"); } else { builder.append("priority ["); for (int i = 0; i < weights.length; ++i) { if (i != 0) { builder.append(", "); } builder.append(weights[i]); } builder.append("]"); } if (seq != 0) { builder.append(" + ") .append(seq); } return builder.toString(); } private  Priority(int[] weights, int seq); static Priority getDefault(); static Priority create(int weight, int... weights); boolean isDefault(); Priority next(); @Override boolean equals(Object obj); @Override int hashCode(); @Override int compareTo(Priority o); @Override String toString();  }