@Test public void compareTo_differentPosition() { final BrowserPattern pattern1 = new BrowserPattern(1, Pattern.compile("[0-9]+"), 1); final BrowserPattern pattern2 = new BrowserPattern(1, Pattern.compile("[0-9]+"), 2); assertThat(pattern1.compareTo(pattern2)).isEqualTo(-1); assertThat(pattern2.compareTo(pattern1)).isEqualTo(1); }
@Override public int compareTo(final BrowserPattern other) { int result = other == null ? -1 : 0; if (result == 0) { result = compareInt(getPosition(), other.getPosition()); if (result == 0) { result = compareInt(getId(), other.getId()); } if (result == 0) { result = getPattern().pattern().compareTo(other.getPattern().pattern()); } if (result == 0) { result = compareInt(getPattern().flags(), other.getPattern().flags()); } } return result; }
BrowserPattern implements Identifiable, OrderedPattern<BrowserPattern>, Serializable { @Override public int compareTo(final BrowserPattern other) { int result = other == null ? -1 : 0; if (result == 0) { result = compareInt(getPosition(), other.getPosition()); if (result == 0) { result = compareInt(getId(), other.getId()); } if (result == 0) { result = getPattern().pattern().compareTo(other.getPattern().pattern()); } if (result == 0) { result = compareInt(getPattern().flags(), other.getPattern().flags()); } } return result; } }
BrowserPattern implements Identifiable, OrderedPattern<BrowserPattern>, Serializable { @Override public int compareTo(final BrowserPattern other) { int result = other == null ? -1 : 0; if (result == 0) { result = compareInt(getPosition(), other.getPosition()); if (result == 0) { result = compareInt(getId(), other.getId()); } if (result == 0) { result = getPattern().pattern().compareTo(other.getPattern().pattern()); } if (result == 0) { result = compareInt(getPattern().flags(), other.getPattern().flags()); } } return result; } BrowserPattern(@Nonnegative final int id, @Nonnull final Pattern pattern, @Nonnegative final int position); }
BrowserPattern implements Identifiable, OrderedPattern<BrowserPattern>, Serializable { @Override public int compareTo(final BrowserPattern other) { int result = other == null ? -1 : 0; if (result == 0) { result = compareInt(getPosition(), other.getPosition()); if (result == 0) { result = compareInt(getId(), other.getId()); } if (result == 0) { result = getPattern().pattern().compareTo(other.getPattern().pattern()); } if (result == 0) { result = compareInt(getPattern().flags(), other.getPattern().flags()); } } return result; } BrowserPattern(@Nonnegative final int id, @Nonnull final Pattern pattern, @Nonnegative final int position); @Override int compareTo(final BrowserPattern other); @Override boolean equals(final Object obj); @Override int getId(); @Override Pattern getPattern(); @Override int getPosition(); @Override int hashCode(); @Override String toString(); }
BrowserPattern implements Identifiable, OrderedPattern<BrowserPattern>, Serializable { @Override public int compareTo(final BrowserPattern other) { int result = other == null ? -1 : 0; if (result == 0) { result = compareInt(getPosition(), other.getPosition()); if (result == 0) { result = compareInt(getId(), other.getId()); } if (result == 0) { result = getPattern().pattern().compareTo(other.getPattern().pattern()); } if (result == 0) { result = compareInt(getPattern().flags(), other.getPattern().flags()); } } return result; } BrowserPattern(@Nonnegative final int id, @Nonnull final Pattern pattern, @Nonnegative final int position); @Override int compareTo(final BrowserPattern other); @Override boolean equals(final Object obj); @Override int getId(); @Override Pattern getPattern(); @Override int getPosition(); @Override int hashCode(); @Override String toString();  }