You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-dev@jackrabbit.apache.org by "rishabhdaim (via GitHub)" <gi...@apache.org> on 2025/01/23 14:42:27 UTC
[PR] OAK-11427 : removed usage of Guava Iterables.isEmpty [jackrabbit-oak]
rishabhdaim opened a new pull request, #2023:
URL: https://github.com/apache/jackrabbit-oak/pull/2023
(no comment)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11427 : removed usage of Guava Iterables.isEmpty [jackrabbit-oak]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #2023:
URL: https://github.com/apache/jackrabbit-oak/pull/2023#issuecomment-2610773914
## [](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [91.7% Coverage on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11427 : removed usage of Guava Iterables.isEmpty [jackrabbit-oak]
Posted by "rishabhdaim (via GitHub)" <gi...@apache.org>.
rishabhdaim merged PR #2023:
URL: https://github.com/apache/jackrabbit-oak/pull/2023
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11427 : removed usage of Guava Iterables.isEmpty [jackrabbit-oak]
Posted by "github-actions[bot] (via GitHub)" <gi...@apache.org>.
github-actions[bot] commented on PR #2023:
URL: https://github.com/apache/jackrabbit-oak/pull/2023#issuecomment-2609990150
# Commit-Check ✔️
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11427 : removed usage of Guava Iterables.isEmpty [jackrabbit-oak]
Posted by "sonarqubecloud[bot] (via GitHub)" <gi...@apache.org>.
sonarqubecloud[bot] commented on PR #2023:
URL: https://github.com/apache/jackrabbit-oak/pull/2023#issuecomment-2610451878
## [](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023) **Quality Gate passed**
Issues
 [0 New issues](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [0 Accepted issues](https://sonarcloud.io/project/issues?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023&issueStatuses=ACCEPTED)
Measures
 [0 Security Hotspots](https://sonarcloud.io/project/security_hotspots?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true)
 [93.1% Coverage on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023&metric=new_coverage&view=list)
 [0.0% Duplication on New Code](https://sonarcloud.io/component_measures?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023&metric=new_duplicated_lines_density&view=list)
[See analysis details on SonarQube Cloud](https://sonarcloud.io/dashboard?id=org.apache.jackrabbit%3Ajackrabbit-oak&pullRequest=2023)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11427 : removed usage of Guava Iterables.isEmpty [jackrabbit-oak]
Posted by "rishabhdaim (via GitHub)" <gi...@apache.org>.
rishabhdaim commented on code in PR #2023:
URL: https://github.com/apache/jackrabbit-oak/pull/2023#discussion_r1927291351
##########
oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/IterableUtils.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.commons.collections;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+
+/**
+ * Utility methods for {@link Iterable} conversions.
+ */
+public class IterableUtils {
+
+ private IterableUtils() {
+ // no instances for you
+ }
+
+ /**
+ * Checks if an iterable is empty.
+ *
+ * @param iterable the iterable to check, must not be {@code null}
+ * @param <T> the type of elements in the iterable
+ * @return {@code true} if the iterable is empty, {@code false} otherwise
+ * @throws NullPointerException if the iterable is {@code null}
+ */
+ public static <T> boolean isEmpty(@NotNull Iterable<T> iterable) {
+ if (iterable instanceof Collection) {
+ return ((Collection<?>) iterable).isEmpty();
+ }
+ return StreamUtils.toStream(iterable).findAny().isEmpty();
Review Comment:
@reschke I think we should go with https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/IterableUtils.html#isEmpty(java.lang.Iterable).
Will update the PR.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11427 : removed usage of Guava Iterables.isEmpty [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on code in PR #2023:
URL: https://github.com/apache/jackrabbit-oak/pull/2023#discussion_r1927199950
##########
oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/IterableUtils.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.commons.collections;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+
+/**
+ * Utility methods for {@link Iterable} conversions.
+ */
+public class IterableUtils {
+
+ private IterableUtils() {
+ // no instances for you
+ }
+
+ /**
+ * Checks if an iterable is empty.
+ *
+ * @param iterable the iterable to check, must not be {@code null}
+ * @param <T> the type of elements in the iterable
+ * @return {@code true} if the iterable is empty, {@code false} otherwise
+ * @throws NullPointerException if the iterable is {@code null}
+ */
+ public static <T> boolean isEmpty(@NotNull Iterable<T> iterable) {
+ if (iterable instanceof Collection) {
+ return ((Collection<?>) iterable).isEmpty();
+ }
+ return StreamUtils.toStream(iterable).findAny().isEmpty();
Review Comment:
Is that better than simply saying:
iterable.getIterator().hasNext()
?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11427 : removed usage of Guava Iterables.isEmpty [jackrabbit-oak]
Posted by "rishabhdaim (via GitHub)" <gi...@apache.org>.
rishabhdaim commented on code in PR #2023:
URL: https://github.com/apache/jackrabbit-oak/pull/2023#discussion_r1927298970
##########
oak-commons/src/main/java/org/apache/jackrabbit/oak/commons/collections/IterableUtils.java:
##########
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.jackrabbit.oak.commons.collections;
+
+import org.jetbrains.annotations.NotNull;
+
+import java.util.Collection;
+
+/**
+ * Utility methods for {@link Iterable} conversions.
+ */
+public class IterableUtils {
+
+ private IterableUtils() {
+ // no instances for you
+ }
+
+ /**
+ * Checks if an iterable is empty.
+ *
+ * @param iterable the iterable to check, must not be {@code null}
+ * @param <T> the type of elements in the iterable
+ * @return {@code true} if the iterable is empty, {@code false} otherwise
+ * @throws NullPointerException if the iterable is {@code null}
+ */
+ public static <T> boolean isEmpty(@NotNull Iterable<T> iterable) {
+ if (iterable instanceof Collection) {
+ return ((Collection<?>) iterable).isEmpty();
+ }
+ return StreamUtils.toStream(iterable).findAny().isEmpty();
Review Comment:
addressed in https://github.com/apache/jackrabbit-oak/pull/2023/commits/e5cc56fb74baa58169dc9407faed996f7a22b7c5
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] OAK-11427 : removed usage of Guava Iterables.isEmpty [jackrabbit-oak]
Posted by "reschke (via GitHub)" <gi...@apache.org>.
reschke commented on PR #2023:
URL: https://github.com/apache/jackrabbit-oak/pull/2023#issuecomment-2610144777
Maybe
https://commons.apache.org/proper/commons-collections/apidocs/org/apache/commons/collections4/IterableUtils.html#isEmpty(java.lang.Iterable)
?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: oak-dev-unsubscribe@jackrabbit.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org