Skip to content

Commit

Permalink
OAK-11354: Remove usage of Guava Ints.compare()
Browse files Browse the repository at this point in the history
  • Loading branch information
reschke committed Jan 7, 2025
1 parent 5d04e22 commit 92dcdc3
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import net.jpountz.lz4.LZ4FrameInputStream;
import net.jpountz.lz4.LZ4FrameOutputStream;
import org.apache.jackrabbit.guava.common.io.Files;
import org.apache.jackrabbit.guava.common.primitives.Ints;
import org.apache.jackrabbit.oak.commons.Compression;
import org.junit.After;
import org.junit.Before;
Expand Down Expand Up @@ -528,7 +527,7 @@ public TestLine(String line) {

@Override
public int compareTo(TestLine o) {
return Ints.compare(value, o.value);
return Integer.compare(value, o.value);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.security.authorization.accesscontrol;

import org.apache.jackrabbit.guava.common.primitives.Ints;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy;
import org.apache.jackrabbit.oak.commons.PathUtils;

Expand Down Expand Up @@ -53,7 +52,7 @@ private static int compare(JackrabbitAccessControlPolicy policy1, JackrabbitAcce
} else {
int depth1 = PathUtils.getDepth(p1);
int depth2 = PathUtils.getDepth(p2);
return (depth1 == depth2) ? p1.compareTo(p2) : Ints.compare(depth1, depth2);
return (depth1 == depth2) ? p1.compareTo(p2) : Integer.compare(depth1, depth2);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
*/
package org.apache.jackrabbit.oak.security.authorization.accesscontrol;

import org.apache.jackrabbit.guava.common.primitives.Ints;
import org.apache.jackrabbit.api.security.JackrabbitAccessControlPolicy;
import org.apache.jackrabbit.oak.commons.PathUtils;
import org.apache.jackrabbit.oak.spi.security.authorization.accesscontrol.ReadPolicy;
Expand Down Expand Up @@ -90,15 +89,15 @@ public void testEqualDepth() {
public void testPath1Deeper() {
JackrabbitAccessControlPolicy policy1 = when(mock(JackrabbitAccessControlPolicy.class).getPath()).thenReturn("/some/deeper/path").getMock();
JackrabbitAccessControlPolicy policy2 = when(mock(JackrabbitAccessControlPolicy.class).getPath()).thenReturn("/").getMock();
int expected = Ints.compare(PathUtils.getDepth("/some/deeper/path"), PathUtils.getDepth("/"));
int expected = Integer.compare(PathUtils.getDepth("/some/deeper/path"), PathUtils.getDepth("/"));
assertEquals(expected, comparator.compare(policy1, policy2));
}

@Test
public void testPath2Deeper() {
JackrabbitAccessControlPolicy policy1 = when(mock(JackrabbitAccessControlPolicy.class).getPath()).thenReturn("/path").getMock();
JackrabbitAccessControlPolicy policy2 = when(mock(JackrabbitAccessControlPolicy.class).getPath()).thenReturn("/a/deeper/path").getMock();
int expected = Ints.compare(PathUtils.getDepth("/path"), PathUtils.getDepth("/a/deeper/path"));
int expected = Integer.compare(PathUtils.getDepth("/path"), PathUtils.getDepth("/a/deeper/path"));
assertEquals(expected, comparator.compare(policy1, policy2));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
import java.util.Map;
import java.util.Set;

import org.apache.jackrabbit.guava.common.primitives.Ints;
import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;

import joptsimple.BuiltinHelpFormatter;
Expand Down Expand Up @@ -136,7 +135,7 @@ public String format() {

@Override
public int compareTo(OptionCategory that) {
return Ints.compare(this.bean.order(), that.bean.order());
return Integer.compare(this.bean.order(), that.bean.order());
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
import org.apache.jackrabbit.guava.common.collect.AbstractIterator;
import org.apache.jackrabbit.guava.common.collect.Iterators;
import org.apache.jackrabbit.guava.common.collect.PeekingIterator;
import org.apache.jackrabbit.guava.common.primitives.Ints;
import org.apache.jackrabbit.oak.cache.CacheValue;
import org.apache.jackrabbit.oak.commons.collections.CollectionUtils;
import org.apache.jackrabbit.oak.plugins.document.util.Utils;
Expand Down Expand Up @@ -307,7 +306,7 @@ public Revision getBranchRevision() {
*/
public Revision getRevision(int clusterId) {
for (Revision r : revisions) {
int cmp = Ints.compare(r.getClusterId(), clusterId);
int cmp = Integer.compare(r.getClusterId(), clusterId);
if (cmp == 0) {
return r;
} else if (cmp > 0) {
Expand Down Expand Up @@ -449,7 +448,7 @@ public int compareTo(@NotNull RevisionVector other) {
return 1;
}
Revision otherRev = it.next();
int cmp = -Ints.compare(r.getClusterId(), otherRev.getClusterId());
int cmp = -Integer.compare(r.getClusterId(), otherRev.getClusterId());
if (cmp != 0) {
return cmp;
}
Expand Down Expand Up @@ -544,7 +543,7 @@ private static final class RevisionComparator implements Comparator<Revision> {

@Override
public int compare(Revision o1, Revision o2) {
return Ints.compare(o1.getClusterId(), o2.getClusterId());
return Integer.compare(o1.getClusterId(), o2.getClusterId());
}
}
}

0 comments on commit 92dcdc3

Please sign in to comment.