[java-shib-shared] branch main updated: IDP-2083 - Treat NonnullElements as the default for collections
Scott Cantor
cantor.2 at osu.edu
Wed Jun 21 01:04:19 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-shib-shared.
View the commit online:
http://git.shibboleth.net/view/?p=java-shib-shared.git;a=commit;h=4cb165c60e42e70dd168b6b5718ba054d39306fb
The following commit(s) were added to refs/heads/main by this push:
new 4cb165c6 IDP-2083 - Treat NonnullElements as the default for collections
4cb165c6 is described below
commit 4cb165c60e42e70dd168b6b5718ba054d39306fb
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Tue Jun 20 21:04:16 2023 -0400
IDP-2083 - Treat NonnullElements as the default for collections
https://shibboleth.atlassian.net/browse/IDP-2083
Stray cleanup.
---
.../shared/cli/AbstractCommandLineArguments.java | 3 +--
.../spring/servlet/RequestURLPrefixPredicate.java | 6 ++----
.../shared/servlet/HttpServletSupport.java | 3 +--
.../config/IdentifiedComponentManagerTest.java | 3 +--
.../shared/collection/ClassToInstanceMultiMap.java | 22 ++++++++++------------
.../shared/collection/CollectionSupport.java | 13 +++++--------
.../LockableClassToInstanceMultiMap.java | 15 +++++++--------
.../shibboleth/shared/primitive/StringSupport.java | 6 +++---
.../java/support/primitive/StringSupport.java | 3 +--
9 files changed, 31 insertions(+), 43 deletions(-)
diff --git a/shib-cli/src/main/java/net/shibboleth/shared/cli/AbstractCommandLineArguments.java b/shib-cli/src/main/java/net/shibboleth/shared/cli/AbstractCommandLineArguments.java
index a3860999..67aac136 100644
--- a/shib-cli/src/main/java/net/shibboleth/shared/cli/AbstractCommandLineArguments.java
+++ b/shib-cli/src/main/java/net/shibboleth/shared/cli/AbstractCommandLineArguments.java
@@ -30,7 +30,6 @@ import org.slf4j.Logger;
import com.beust.jcommander.Parameter;
import com.google.common.base.Strings;
-import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
import net.shibboleth.shared.collection.CollectionSupport;
@@ -82,7 +81,7 @@ public abstract class AbstractCommandLineArguments implements CommandLineArgumen
/** Spring property sources. */
@Parameter(names = "--propertyFiles")
- @Nonnull @NonnullElements private List<String> propertySources = new ArrayList<>();
+ @Nonnull private List<String> propertySources = new ArrayList<>();
/** RFC4647 language ranges. */
@Parameter(names = "--lang")
diff --git a/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/servlet/RequestURLPrefixPredicate.java b/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/servlet/RequestURLPrefixPredicate.java
index 94f8b47e..8747b69d 100644
--- a/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/servlet/RequestURLPrefixPredicate.java
+++ b/shib-networking-spring/src/main/java/net/shibboleth/shared/spring/servlet/RequestURLPrefixPredicate.java
@@ -28,7 +28,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import net.shibboleth.shared.annotation.ParameterName;
-import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.collection.CollectionSupport;
/**
@@ -37,7 +36,7 @@ import net.shibboleth.shared.collection.CollectionSupport;
public class RequestURLPrefixPredicate implements Predicate<ServletRequest> {
/** Prefixes to check for. */
- @Nonnull @NonnullElements private Collection<URLPrefix> matchingPrefixes;
+ @Nonnull private Collection<URLPrefix> matchingPrefixes;
/**
* Constructor.
@@ -45,8 +44,7 @@ public class RequestURLPrefixPredicate implements Predicate<ServletRequest> {
* @param prefixes prefixes to match
*/
@Autowired
- public RequestURLPrefixPredicate(
- @Nullable @NonnullElements @ParameterName(name="prefixes") final Collection<URLPrefix> prefixes) {
+ public RequestURLPrefixPredicate(@Nullable @ParameterName(name="prefixes") final Collection<URLPrefix> prefixes) {
if (prefixes != null) {
matchingPrefixes = CollectionSupport.copyToList(prefixes);
} else {
diff --git a/shib-networking/src/main/java/net/shibboleth/shared/servlet/HttpServletSupport.java b/shib-networking/src/main/java/net/shibboleth/shared/servlet/HttpServletSupport.java
index 53ea9682..1dfa8bf7 100644
--- a/shib-networking/src/main/java/net/shibboleth/shared/servlet/HttpServletSupport.java
+++ b/shib-networking/src/main/java/net/shibboleth/shared/servlet/HttpServletSupport.java
@@ -32,7 +32,6 @@ import com.google.common.net.MediaType;
import jakarta.servlet.ServletRequest;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
-import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
import net.shibboleth.shared.collection.CollectionSupport;
@@ -144,7 +143,7 @@ public final class HttpServletSupport {
* @return true if the content type is valid, false if not
*/
public static boolean validateContentType(@Nonnull final HttpServletRequest request,
- @Nonnull @NonnullElements final Set<MediaType> validTypes, final boolean noContentTypeIsValid,
+ @Nonnull final Set<MediaType> validTypes, final boolean noContentTypeIsValid,
final boolean isOneOfStrategy) {
return MediaTypeSupport.validateContentType(request.getContentType(), validTypes,
diff --git a/shib-spring/src/test/java/net/shibboleth/shared/spring/config/IdentifiedComponentManagerTest.java b/shib-spring/src/test/java/net/shibboleth/shared/spring/config/IdentifiedComponentManagerTest.java
index 7dd43e5d..601bf40a 100644
--- a/shib-spring/src/test/java/net/shibboleth/shared/spring/config/IdentifiedComponentManagerTest.java
+++ b/shib-spring/src/test/java/net/shibboleth/shared/spring/config/IdentifiedComponentManagerTest.java
@@ -30,7 +30,6 @@ import org.springframework.context.support.GenericApplicationContext;
import org.testng.Assert;
import org.testng.annotations.Test;
-import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.component.AbstractIdentifiableInitializableComponent;
import net.shibboleth.shared.spring.custom.SchemaTypeAwareXMLBeanDefinitionReader;
@@ -163,7 +162,7 @@ public class IdentifiedComponentManagerTest {
* @param freeObjects free-standing objects
*/
@Autowired
- public MockComponentManager(@Nonnull @NonnullElements final Collection<MockComponent> freeObjects) {
+ public MockComponentManager(@Nonnull final Collection<MockComponent> freeObjects) {
super(freeObjects);
}
}
diff --git a/shib-support/src/main/java/net/shibboleth/shared/collection/ClassToInstanceMultiMap.java b/shib-support/src/main/java/net/shibboleth/shared/collection/ClassToInstanceMultiMap.java
index 2228d3af..57e81187 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/collection/ClassToInstanceMultiMap.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/collection/ClassToInstanceMultiMap.java
@@ -18,7 +18,6 @@
package net.shibboleth.shared.collection;
import net.shibboleth.shared.annotation.constraint.Live;
-import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
import net.shibboleth.shared.logic.Constraint;
@@ -53,7 +52,7 @@ public class ClassToInstanceMultiMap<B> {
@Nonnull private final HashMap<Class<?>, List<B>> backingMap;
/** List of values that are indexed. */
- @Nonnull @NonnullElements private final List<B> values;
+ @Nonnull private final List<B> values;
/** Constructor. Does not index supertypes. */
public ClassToInstanceMultiMap() {
@@ -115,7 +114,7 @@ public class ClassToInstanceMultiMap<B> {
*
* @return instances mapped to the given type or an empty list
*/
- @Nonnull @NonnullElements @Unmodifiable @Live public <T> List<T> get(@Nullable final Class<T> type) {
+ @Nonnull @Unmodifiable @Live public <T> List<T> get(@Nullable final Class<T> type) {
if (type == null) {
return CollectionSupport.emptyList();
}
@@ -142,7 +141,7 @@ public class ClassToInstanceMultiMap<B> {
*
* @return set of keys contained in this map
*/
- @Nonnull @NonnullElements @Unmodifiable @Live public Set<Class<?>> keys() {
+ @Nonnull @Unmodifiable @Live public Set<Class<?>> keys() {
return Collections.unmodifiableSet(backingMap.keySet());
}
@@ -185,7 +184,7 @@ public class ClassToInstanceMultiMap<B> {
*
* @see ClassToInstanceMultiMap#put(Object)
*/
- public void putAll(@Nullable @NonnullElements final Iterable<? extends B> newValues) {
+ public void putAll(@Nullable final Iterable<? extends B> newValues) {
if (newValues == null) {
return;
}
@@ -205,7 +204,7 @@ public class ClassToInstanceMultiMap<B> {
*
* @see ClassToInstanceMultiMap#put(Object)
*/
- public void putAll(@Nullable @NonnullElements final ClassToInstanceMultiMap<? extends B> map) {
+ public void putAll(@Nullable final ClassToInstanceMultiMap<? extends B> map) {
if (map == null) {
return;
}
@@ -250,7 +249,7 @@ public class ClassToInstanceMultiMap<B> {
*
* @param removeValues the values to remove
*/
- public void removeAll(@Nullable @NonnullElements final Iterable<? extends B> removeValues) {
+ public void removeAll(@Nullable final Iterable<? extends B> removeValues) {
if (removeValues == null) {
return;
}
@@ -270,7 +269,7 @@ public class ClassToInstanceMultiMap<B> {
*
* @param map the map containing the values to remove
*/
- public void removeAll(@Nullable @NonnullElements final ClassToInstanceMultiMap<? extends B> map) {
+ public void removeAll(@Nullable final ClassToInstanceMultiMap<? extends B> map) {
if (map == null) {
return;
}
@@ -314,7 +313,7 @@ public class ClassToInstanceMultiMap<B> {
*
* @return collection of values currently present in the map
*/
- @Nonnull @NonnullElements @Unmodifiable @Live public Collection<? extends B> values() {
+ @Nonnull @Unmodifiable @Live public Collection<? extends B> values() {
return Collections.unmodifiableList(values);
}
@@ -324,7 +323,7 @@ public class ClassToInstanceMultiMap<B> {
* @param value the value to index
* @return the set of classes by which to index the value
*/
- @Nonnull @NonnullElements private Set<Class<?>> getIndexTypes(@Nonnull final B value) {
+ @Nonnull private Set<Class<?>> getIndexTypes(@Nonnull final B value) {
final HashSet<Class<?>> indexTypes = new HashSet<>();
indexTypes.add(value.getClass());
@@ -341,8 +340,7 @@ public class ClassToInstanceMultiMap<B> {
* @param clazz class for which supertypes will be determined
* @param accumulator collection to which supertypes are added as they are determined
*/
- private void getSuperTypes(@Nonnull final Class<?> clazz,
- @Nonnull @NonnullElements final Set<Class<?>> accumulator) {
+ private void getSuperTypes(@Nonnull final Class<?> clazz, @Nonnull @Live final Set<Class<?>> accumulator) {
final Class<?> superclass = clazz.getSuperclass();
if (superclass != null && superclass != Object.class) {
accumulator.add(superclass);
diff --git a/shib-support/src/main/java/net/shibboleth/shared/collection/CollectionSupport.java b/shib-support/src/main/java/net/shibboleth/shared/collection/CollectionSupport.java
index 70522a23..9f6539c8 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/collection/CollectionSupport.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/collection/CollectionSupport.java
@@ -33,7 +33,6 @@ import javax.annotation.Nullable;
import org.slf4j.Logger;
-import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
import net.shibboleth.shared.logic.Constraint;
@@ -184,8 +183,7 @@ public final class CollectionSupport {
* @return immutable copied list
*/
@SuppressWarnings("null")
- @Nonnull @NonnullElements @Unmodifiable @NotLive public static <T> List<T> copyToList(
- @Nonnull @NonnullElements final Collection<? extends T> coll) {
+ @Nonnull @Unmodifiable @NotLive public static <T> List<T> copyToList(@Nonnull final Collection<? extends T> coll) {
return List.copyOf(coll);
}
@@ -277,8 +275,7 @@ public final class CollectionSupport {
* @return immutable copied set
*/
@SuppressWarnings("null")
- @Nonnull @NonnullElements @Unmodifiable @NotLive public static <T> Set<T> copyToSet(
- @Nonnull @NonnullElements final Collection<? extends T> coll) {
+ @Nonnull @Unmodifiable @NotLive public static <T> Set<T> copyToSet(@Nonnull final Collection<? extends T> coll) {
return Set.copyOf(coll);
}
@@ -307,7 +304,7 @@ public final class CollectionSupport {
* @return singleton amp
*/
@SuppressWarnings("null")
- @Nonnull @NonnullElements @Unmodifiable @NotLive public static <T,U> Map<T,U> singletonMap(@Nonnull final T key,
+ @Nonnull @Unmodifiable @NotLive public static <T,U> Map<T,U> singletonMap(@Nonnull final T key,
@Nullable final U value) {
return Collections.singletonMap(key, value);
}
@@ -323,7 +320,7 @@ public final class CollectionSupport {
* @return immutable copied map
*/
@SuppressWarnings("null")
- @Nonnull @NonnullElements @Unmodifiable @NotLive public static <U,T> Map<U,T> copyToMap(
+ @Nonnull @Unmodifiable @NotLive public static <U,T> Map<U,T> copyToMap(
@Nonnull final Map<? extends U, ? extends T> map) {
return Map.copyOf(map);
}
@@ -336,7 +333,7 @@ public final class CollectionSupport {
*/
@SafeVarargs
@SuppressWarnings("null")
- @Nonnull @NonnullElements @Unmodifiable @NotLive public static <T> List<T> arrayAsList(@Nonnull final T... a) {
+ @Nonnull @Unmodifiable @NotLive public static <T> List<T> arrayAsList(@Nonnull final T... a) {
return Arrays.asList(a);
}
}
\ No newline at end of file
diff --git a/shib-support/src/main/java/net/shibboleth/shared/collection/LockableClassToInstanceMultiMap.java b/shib-support/src/main/java/net/shibboleth/shared/collection/LockableClassToInstanceMultiMap.java
index 4e2b5ebe..44f932b3 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/collection/LockableClassToInstanceMultiMap.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/collection/LockableClassToInstanceMultiMap.java
@@ -28,7 +28,6 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import net.shibboleth.shared.annotation.constraint.Live;
-import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
/**
@@ -140,7 +139,7 @@ public class LockableClassToInstanceMultiMap<B> extends ClassToInstanceMultiMap<
*
* @return instances mapped to the given type or an empty list
*/
- @Nonnull @NonnullElements @Unmodifiable @Live public <T> List<T> getWithLock(@Nullable final Class<T> type) {
+ @Nonnull @Unmodifiable @Live public <T> List<T> getWithLock(@Nullable final Class<T> type) {
final Lock readLock = getReadWriteLock().readLock();
try {
readLock.lock();
@@ -172,7 +171,7 @@ public class LockableClassToInstanceMultiMap<B> extends ClassToInstanceMultiMap<
*
* @return set of keys contained in this map
*/
- @Nonnull @NonnullElements @Unmodifiable @Live public Set<Class<?>> keysWithLock() {
+ @Nonnull @Unmodifiable @Live public Set<Class<?>> keysWithLock() {
final Lock readLock = getReadWriteLock().readLock();
try {
readLock.lock();
@@ -204,7 +203,7 @@ public class LockableClassToInstanceMultiMap<B> extends ClassToInstanceMultiMap<
*
* @param map map containing values to be added
*/
- public void putAllWithLock(@Nullable @NonnullElements final ClassToInstanceMultiMap<? extends B> map) {
+ public void putAllWithLock(@Nullable final ClassToInstanceMultiMap<? extends B> map) {
final Lock writeLock = getReadWriteLock().writeLock();
try {
writeLock.lock();
@@ -220,7 +219,7 @@ public class LockableClassToInstanceMultiMap<B> extends ClassToInstanceMultiMap<
*
* @param newValues values to be added
*/
- public void putAllWithLock(@Nullable @NonnullElements final Iterable<? extends B> newValues) {
+ public void putAllWithLock(@Nullable final Iterable<? extends B> newValues) {
final Lock writeLock = getReadWriteLock().writeLock();
try {
writeLock.lock();
@@ -268,7 +267,7 @@ public class LockableClassToInstanceMultiMap<B> extends ClassToInstanceMultiMap<
*
* @param map the map containing the values to remove
*/
- public void removeAllWithLock(@Nullable @NonnullElements final ClassToInstanceMultiMap<? extends B> map) {
+ public void removeAllWithLock(@Nullable final ClassToInstanceMultiMap<? extends B> map) {
final Lock writeLock = getReadWriteLock().writeLock();
try {
writeLock.lock();
@@ -283,7 +282,7 @@ public class LockableClassToInstanceMultiMap<B> extends ClassToInstanceMultiMap<
*
* @param removeValues the values to remove
*/
- public void removeAllWithLock(@Nullable @NonnullElements final Iterable<? extends B> removeValues) {
+ public void removeAllWithLock(@Nullable final Iterable<? extends B> removeValues) {
final Lock writeLock = getReadWriteLock().writeLock();
try {
writeLock.lock();
@@ -299,7 +298,7 @@ public class LockableClassToInstanceMultiMap<B> extends ClassToInstanceMultiMap<
*
* @return collection of values currently present in the map
*/
- @Nonnull @NonnullElements @Unmodifiable @Live public Collection<? extends B> valuesWithLock() {
+ @Nonnull @Unmodifiable @Live public Collection<? extends B> valuesWithLock() {
final Lock readLock = getReadWriteLock().readLock();
try {
readLock.lock();
diff --git a/shib-support/src/main/java/net/shibboleth/shared/primitive/StringSupport.java b/shib-support/src/main/java/net/shibboleth/shared/primitive/StringSupport.java
index b361feba..4c5acba0 100644
--- a/shib-support/src/main/java/net/shibboleth/shared/primitive/StringSupport.java
+++ b/shib-support/src/main/java/net/shibboleth/shared/primitive/StringSupport.java
@@ -35,7 +35,6 @@ import javax.annotation.Nullable;
import com.google.common.base.Predicates;
-import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NullableElements;
import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.logic.Constraint;
@@ -175,7 +174,7 @@ public final class StringSupport {
* @param values the collection of string values
* @return the normalized collection of string values
*/
- @Nonnull @NonnullElements public static Collection<String> normalizeStringCollection(
+ @Nonnull public static Collection<String> normalizeStringCollection(
@Nullable @NullableElements final Collection<String> values) {
if (values == null) {
return CollectionSupport.emptyList();
@@ -209,4 +208,5 @@ public final class StringSupport {
throw new ConstraintViolationException("XML Booleans must be 0/1/true/false");
}
-}
+
+}
\ No newline at end of file
diff --git a/shib-support/src/main/java/net/shibboleth/utilities/java/support/primitive/StringSupport.java b/shib-support/src/main/java/net/shibboleth/utilities/java/support/primitive/StringSupport.java
index 11f6eaf4..8535435b 100644
--- a/shib-support/src/main/java/net/shibboleth/utilities/java/support/primitive/StringSupport.java
+++ b/shib-support/src/main/java/net/shibboleth/utilities/java/support/primitive/StringSupport.java
@@ -27,7 +27,6 @@ import java.util.StringTokenizer;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
-import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NullableElements;
import net.shibboleth.shared.primitive.DeprecationSupport;
import net.shibboleth.shared.primitive.DeprecationSupport.ObjectType;
@@ -133,7 +132,7 @@ public final class StringSupport {
* @param values the collection of string values
* @return the normalized collection of string values
*/
- @Nonnull @NonnullElements public static Collection<String> normalizeStringCollection(
+ @Nonnull public static Collection<String> normalizeStringCollection(
@Nullable @NullableElements final Collection<String> values) {
DeprecationSupport.warn(ObjectType.CLASS, StringSupport.class.getName(), null,
net.shibboleth.shared.primitive.StringSupport.class.getName());
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list