Skip to content

Commit

Permalink
OAK-11012: Remove usage of Guava Objects.equal() (apache#1634)
Browse files Browse the repository at this point in the history
  • Loading branch information
reschke authored Aug 10, 2024
1 parent 8bdd8fb commit e4db4c6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.jackrabbit.oak.commons;

import static org.apache.jackrabbit.guava.common.base.Objects.equal;
import static java.lang.Boolean.parseBoolean;
import static java.lang.System.getenv;

import java.util.Objects;

import org.apache.jackrabbit.guava.common.base.StandardSystemProperty;

/**
Expand Down Expand Up @@ -57,23 +57,23 @@ public static boolean travis() {
* @deprecated Travis builds do not use PROFILE anymore. Use {@link #travis()} instead.
*/
public static boolean travisPedantic() {
return equal(getenv("PROFILE"), "pedantic");
return Objects.equals(getenv("PROFILE"), "pedantic");
}

/**
* @return {@code true} iff running on with {@code PROFILE=unittesting}
* @deprecated Travis builds do not use PROFILE anymore. Use {@link #travis()} instead.
*/
public static boolean travisUnitTesting() {
return equal(getenv("PROFILE"), "unittesting");
return Objects.equals(getenv("PROFILE"), "unittesting");
}

/**
* @return {@code true} iff running on with {@code PROFILE=integrationTesting}
* @deprecated Travis builds do not use PROFILE anymore. Use {@link #travis()} instead.
*/
public static boolean travisIntegrationTesting() {
return equal(getenv("PROFILE"), "integrationTesting");
return Objects.equals(getenv("PROFILE"), "integrationTesting");
}

public static boolean jenkinsNodeLabel(String label) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
package org.apache.jackrabbit.oak.jcr.observation;

import static org.apache.jackrabbit.guava.common.collect.Sets.newHashSet;
import static org.apache.jackrabbit.guava.common.base.Objects.equal;

import static java.util.Collections.synchronizedList;
import static java.util.Collections.synchronizedSet;
import static java.util.concurrent.Executors.newSingleThreadScheduledExecutor;
Expand Down Expand Up @@ -48,6 +48,7 @@
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
Expand Down Expand Up @@ -1257,7 +1258,7 @@ public Expectation expect(Expectation expectation) {
expected.add(expectation);
return expectation;
}

public Expectation optional(Expectation expectation) {
if (failed != null) {
expectation.fail(failed);
Expand All @@ -1270,7 +1271,7 @@ public Future<Event> expect(final String path, final int type) {
return expect(new Expectation("path = " + path + ", type = " + type) {
@Override
public boolean onEvent(Event event) throws RepositoryException {
return type == event.getType() && equal(path, event.getPath());
return type == event.getType() && Objects.equals(path, event.getPath());
}
});
}
Expand All @@ -1279,7 +1280,7 @@ public Future<Event> expect(final String path, final String identifier, final in
return expect(new Expectation("path = " + path + ", identifier = " + identifier + ", type = " + type) {
@Override
public boolean onEvent(Event event) throws RepositoryException {
return type == event.getType() && equal(path, event.getPath()) && equal(identifier, event.getIdentifier());
return type == event.getType() && Objects.equals(path, event.getPath()) && Objects.equals(identifier, event.getIdentifier());
}
});
}
Expand Down Expand Up @@ -1316,9 +1317,9 @@ public void expectMove(final String src, final String dst) {
@Override
public boolean onEvent(Event event) throws Exception {
return event.getType() == NODE_MOVED &&
equal(dst, event.getPath()) &&
equal(src, event.getInfo().get("srcAbsPath")) &&
equal(dst, event.getInfo().get("destAbsPath"));
Objects.equals(dst, event.getPath()) &&
Objects.equals(src, event.getInfo().get("srcAbsPath")) &&
Objects.equals(dst, event.getInfo().get("destAbsPath"));
}
});
}
Expand All @@ -1327,8 +1328,8 @@ public void expectValue(final Value before, final Value after) {
expect(new Expectation("Before value " + before + " after value " + after) {
@Override
public boolean onEvent(Event event) throws Exception {
return equal(before, event.getInfo().get("beforeValue")) &&
equal(after, event.getInfo().get("afterValue"));
return Objects.equals(before, event.getInfo().get("beforeValue")) &&
Objects.equals(after, event.getInfo().get("afterValue"));
}
});
}
Expand All @@ -1347,7 +1348,7 @@ public Future<Event> expectBeforeValue(final String path, final int type, final
return expect(new Expectation("path = " + path + ", type = " + type + ", beforeValue = " + beforeValue) {
@Override
public boolean onEvent(Event event) throws RepositoryException {
return type == event.getType() && equal(path, event.getPath()) && event.getInfo().containsKey("beforeValue") && beforeValue.equals(((Value)event.getInfo().get("beforeValue")).getString());
return type == event.getType() && Objects.equals(path, event.getPath()) && event.getInfo().containsKey("beforeValue") && beforeValue.equals(((Value)event.getInfo().get("beforeValue")).getString());
}
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import java.util.NavigableSet;
import java.util.Objects;
import java.util.Set;
import java.util.TreeSet;
import java.util.concurrent.TimeUnit;
Expand All @@ -41,7 +42,6 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.apache.jackrabbit.guava.common.base.Objects.equal;
import static org.apache.jackrabbit.guava.common.base.Preconditions.checkNotNull;
import static org.apache.jackrabbit.guava.common.collect.Iterables.filter;
import static org.apache.jackrabbit.guava.common.collect.Iterables.transform;
Expand Down Expand Up @@ -697,7 +697,7 @@ private String formatConflictRevision(Revision r) {
return r + " (not yet visible)";
} else if (baseRevision != null
&& !baseRevision.isRevisionNewer(r)
&& !equal(baseRevision.getRevision(r.getClusterId()), r)) {
&& !Objects.equals(baseRevision.getRevision(r.getClusterId()), r)) {
return r + " (older than base " + baseRevision + ")";
} else {
return r.toString();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import java.util.Map;
import java.util.Map.Entry;
import java.util.NavigableMap;
import java.util.Objects;
import java.util.Queue;
import java.util.Set;
import java.util.SortedMap;
Expand Down Expand Up @@ -60,7 +61,7 @@
import org.apache.jackrabbit.guava.common.collect.Sets;

import static java.util.stream.Collectors.toSet;
import static org.apache.jackrabbit.guava.common.base.Objects.equal;

import static org.apache.jackrabbit.guava.common.base.Preconditions.checkArgument;
import static org.apache.jackrabbit.guava.common.base.Preconditions.checkNotNull;
import static org.apache.jackrabbit.guava.common.collect.ImmutableList.copyOf;
Expand Down Expand Up @@ -744,7 +745,7 @@ Revision getNewestRevision(final RevisionContext context,
clusterIds = Sets.newHashSet();
for (Revision prevRev : getPreviousRanges().keySet()) {
if (lower.isRevisionNewer(prevRev) ||
equal(prevRev, lower.getRevision(prevRev.getClusterId()))) {
Objects.equals(prevRev, lower.getRevision(prevRev.getClusterId()))) {
clusterIds.add(prevRev.getClusterId());
}
}
Expand Down

0 comments on commit e4db4c6

Please sign in to comment.