/** * Returns the {@link RevisionRange} whose major value of {@code from} {@link Revision} is greater than * or equal to the major value of {@code to} {@link Revision}. * * @throws IllegalStateException if the {@code from} and {@code to} {@link Revision}s are in the * different state. They should be either absolute or relative. */ public RevisionRange toDescending() { if (isAscending()) { return new RevisionRange(to, from); } return this; }
/** * Returns the {@link RevisionRange} whose major value of {@code from} {@link Revision} is greater than * or equal to the major value of {@code to} {@link Revision}. * * @throws IllegalStateException if the {@code from} and {@code to} {@link Revision}s are in the * different state. They should be either absolute or relative. */ public RevisionRange toDescending() { if (isAscending()) { return new RevisionRange(to, from); } return this; }
/** * Returns the {@link RevisionRange} whose major value of {@code from} {@link Revision} is greater than * or equal to the major value of {@code to} {@link Revision}. * * @throws IllegalStateException if the {@code from} and {@code to} {@link Revision}s are in the * different state. They should be either absolute or relative. */ public RevisionRange toDescending() { if (isAscending()) { return new RevisionRange(to, from); } return this; }
/** * Returns the {@link RevisionRange} whose major value of {@code from} {@link Revision} is lower than * or equal to the major value of {@code to} {@link Revision}. * * @throws IllegalStateException if the {@code from} and {@code to} {@link Revision}s are in the * different state. They should be either absolute or relative. */ public RevisionRange toAscending() { if (isAscending() || from.equals(to)) { return this; } return new RevisionRange(to, from); }
/** * Returns the {@link RevisionRange} whose major value of {@code from} {@link Revision} is lower than * or equal to the major value of {@code to} {@link Revision}. * * @throws IllegalStateException if the {@code from} and {@code to} {@link Revision}s are in the * different state. They should be either absolute or relative. */ public RevisionRange toAscending() { if (isAscending() || from.equals(to)) { return this; } return new RevisionRange(to, from); }
/** * Returns the {@link RevisionRange} whose major value of {@code from} {@link Revision} is lower than * or equal to the major value of {@code to} {@link Revision}. * * @throws IllegalStateException if the {@code from} and {@code to} {@link Revision}s are in the * different state. They should be either absolute or relative. */ public RevisionRange toAscending() { if (isAscending() || from.equals(to)) { return this; } return new RevisionRange(to, from); }
RevisionRange range = new RevisionRange(2, 4); assertThat(range.isAscending()).isTrue(); assertThat(range.isRelative()).isFalse(); assertThat(range.toAscending()).isSameAs(range); range = new RevisionRange(revisionTen, INIT); assertThat(range.isAscending()).isFalse(); assertThat(range.isRelative()).isFalse(); assertThat(range.toAscending()).isEqualTo(new RevisionRange(INIT, revisionTen)); assertThat(range.isAscending()).isFalse(); assertThat(range.isRelative()).isFalse(); assertThat(range.toAscending()).isSameAs(range); range = new RevisionRange(revisionNegativeTen, revisionNegativeThree); assertThat(range.isAscending()).isTrue(); assertThat(range.isRelative()).isTrue(); assertThat(range.toAscending()).isSameAs(range);