Skip to content

Commit

Permalink
OAK-11311: Remove usage of Guava ImmutableList - oak-core-spi
Browse files Browse the repository at this point in the history
  • Loading branch information
reschke committed Dec 19, 2024
1 parent 0083a8f commit 76d6604
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.List;
import java.util.Map;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import javax.management.MalformedObjectNameException;
import javax.management.ObjectName;
Expand All @@ -30,9 +31,6 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import org.apache.jackrabbit.guava.common.collect.ImmutableList;
import org.apache.jackrabbit.guava.common.collect.Iterables;

import static org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.ScheduleExecutionInstanceTypes.DEFAULT;
import static org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.ScheduleExecutionInstanceTypes.RUN_ON_LEADER;
import static org.apache.jackrabbit.oak.spi.whiteboard.WhiteboardUtils.ScheduleExecutionInstanceTypes.RUN_ON_SINGLE;
Expand Down Expand Up @@ -165,7 +163,7 @@ public static <T> List<T> getServices(@NotNull Whiteboard wb, @NotNull Class<T>
if (predicate == null) {
return tracker.getServices();
} else {
return ImmutableList.copyOf(Iterables.filter(tracker.getServices(), (input) -> predicate.test(input)));
return tracker.getServices().stream().filter(predicate).collect(Collectors.toUnmodifiableList());
}
} finally {
tracker.stop();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,23 +16,22 @@
* specific language governing permissions and limitations
* under the License.
*/

package org.apache.jackrabbit.oak.spi.mount;

import static org.apache.jackrabbit.guava.common.collect.ImmutableList.of;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import org.apache.jackrabbit.oak.spi.mount.MountInfo;
import org.junit.Test;

import java.util.Collections;
import java.util.List;

public class MountInfoTest {

@Test
public void testIsMounted() throws Exception{
MountInfo md = new MountInfo("foo", false, of("/x/y"), of("/a", "/b"));
MountInfo md = new MountInfo("foo", false, List.of("/x/y"), List.of("/a", "/b"));
assertTrue(md.isMounted("/a"));
assertTrue(md.isMounted("/b"));
assertTrue(md.isMounted("/b/c/d"));
Expand All @@ -45,7 +44,7 @@ public void testIsMounted() throws Exception{

@Test
public void testIsUnder() {
MountInfo md = new MountInfo("foo", false, Collections.<String>emptyList(), of("/apps", "/etc/config", "/content/my/site", "/var"));
MountInfo md = new MountInfo("foo", false, Collections.emptyList(), List.of("/apps", "/etc/config", "/content/my/site", "/var"));
assertTrue(md.isUnder("/etc"));
assertTrue(md.isUnder("/content"));
assertTrue(md.isUnder("/content/my"));
Expand All @@ -56,7 +55,7 @@ public void testIsUnder() {

@Test
public void testIsDirectlyUnder() {
MountInfo md = new MountInfo("foo", false, Collections.<String>emptyList(), of("/apps", "/etc/my/config", "/var"));
MountInfo md = new MountInfo("foo", false, Collections.<String>emptyList(), List.of("/apps", "/etc/my/config", "/var"));
assertFalse(md.isDirectlyUnder("/etc"));
assertTrue(md.isDirectlyUnder("/etc/my"));
assertFalse(md.isDirectlyUnder("/etc/my/config"));
Expand All @@ -65,7 +64,7 @@ public void testIsDirectlyUnder() {

@Test
public void testSupportFragment() {
MountInfo md = new MountInfo("foo", false, of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList());
MountInfo md = new MountInfo("foo", false, List.of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList());

assertFalse(md.isSupportFragment("/"));
assertTrue(md.isSupportFragment("/apps"));
Expand All @@ -86,7 +85,7 @@ public void testSupportFragment() {

@Test
public void testSupportFragmentUnder() {
MountInfo md = new MountInfo("foo", false, of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList());
MountInfo md = new MountInfo("foo", false, List.of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList());

assertTrue(md.isSupportFragmentUnder("/"));
assertTrue(md.isSupportFragmentUnder("/apps"));
Expand All @@ -107,7 +106,7 @@ public void testSupportFragmentUnder() {

@Test
public void testIsMountedWithFragments() {
MountInfo md = new MountInfo("foo", false, of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList());
MountInfo md = new MountInfo("foo", false, List.of("/apps", "/libs/*/site", "/content/*$", "/var$"), Collections.emptyList());

assertFalse(md.isMounted("/oak:mount-foo"));
assertTrue(md.isMounted("/apps/oak:mount-foo"));
Expand Down

0 comments on commit 76d6604

Please sign in to comment.