public int compare(ProcessFactory pf1, ProcessFactory pf2) { if (pf1.getTitle() == null) { if (pf2.getTitle() == null) { return 0; } else { return -1; } } else { if (pf2.getTitle() == null) { return 1; } else { return pf1.getTitle().compareTo(pf2.getTitle()); } } } };
public int compare(ProcessFactory pf1, ProcessFactory pf2) { if (pf1.getTitle() == null) { if (pf2.getTitle() == null) { return 0; } else { return -1; } } else { if (pf2.getTitle() == null) { return 1; } else { return pf1.getTitle().compareTo(pf2.getTitle()); } } } };
/** * Ensures that the {@link CharSequence} methods are consistent with the {@code toString()} value. * * @param object The object to validate, or {@code null}. */ public void validate(final InternationalString object) { if (object == null) { return; } final int length = object.length(); final String s = object.toString(); mandatory("InternationalString: toString() should never returns null.", s); if (s != null) { assertEquals("InternationalString: CharSequence length is inconsistent with toString().", s.length(), length); for (int i=0; i<length; i++) { assertEquals("InternationalString: CharSequence is inconsistent with toString().", s.charAt(i), object.charAt(i)); } } mandatory("InternationalString: toString(Locale) should not return null.", object.toString(null)); assertEquals("InternationalString: should be equals to itself.", object, object); assertEquals("InternationalString: should be comparable to itself.", 0, object.compareTo(object)); }
/** * Ensures that the {@link CharSequence} methods are consistent with the {@code toString()} value. * * @param object the object to validate, or {@code null}. */ public void validate(final InternationalString object) { if (object == null) { return; } final int length = object.length(); final String s = object.toString(); mandatory("CharSequence: toString() shall never returns null.", s); if (s != null) { assertEquals("CharSequence: length is inconsistent with toString() length.", s.length(), length); boolean expectLowSurrogate = false; for (int i=0; i<length; i++) { final char c = s.charAt(i); assertEquals("CharSequence: character inconsistent with toString().", c, object.charAt(i)); if (expectLowSurrogate) { assertTrue("CharSequence: High surrogate shall be followed by low surrogate.", Character.isLowSurrogate(c)); } expectLowSurrogate = Character.isHighSurrogate(c); } assertFalse("CharSequence: High surrogate shall be followed by low surrogate.", expectLowSurrogate); } mandatory("InternationalString: toString(Locale) shall not return null.", object.toString(null)); assertEquals("InternationalString: shall be equal to itself.", object, object); assertEquals("InternationalString: shall be comparable to itself.", 0, object.compareTo(object)); }