[java-opensaml] branch main updated: Add missing annotations.
Scott Cantor
cantor.2 at osu.edu
Thu Mar 9 17:38:54 UTC 2023
This is an automated email from the git hooks/post-receive script.
scantor pushed a commit to branch main
in repository java-opensaml.
View the commit online:
http://git.shibboleth.net/view/?p=java-opensaml.git;a=commit;h=7042e9eefae2542a7fc9f21cac79150af403f0e7
The following commit(s) were added to refs/heads/main by this push:
new 7042e9eef Add missing annotations.
7042e9eef is described below
commit 7042e9eefae2542a7fc9f21cac79150af403f0e7
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Thu Mar 9 12:38:52 2023 -0500
Add missing annotations.
---
.../xml/AbstractElementExtensibleXMLObject.java | 9 +++--
.../xml/AbstractExtensibleXMLObjectMarshaller.java | 2 +-
.../org/opensaml/core/xml/NamespaceManager.java | 24 +++++++-----
.../main/java/org/opensaml/core/xml/XMLObject.java | 5 ++-
.../opensaml/core/xml/XMLObjectBuilderFactory.java | 3 +-
.../org/opensaml/core/xml/util/AttributeMap.java | 43 +++++++++++-----------
.../xml/util/IndexedXMLObjectChildrenList.java | 2 +-
.../core/xml/util/XMLObjectChildrenList.java | 4 +-
8 files changed, 50 insertions(+), 42 deletions(-)
diff --git a/opensaml-core-api/src/main/java/org/opensaml/core/xml/AbstractElementExtensibleXMLObject.java b/opensaml-core-api/src/main/java/org/opensaml/core/xml/AbstractElementExtensibleXMLObject.java
index 609395d88..fa6d59c62 100644
--- a/opensaml-core-api/src/main/java/org/opensaml/core/xml/AbstractElementExtensibleXMLObject.java
+++ b/opensaml-core-api/src/main/java/org/opensaml/core/xml/AbstractElementExtensibleXMLObject.java
@@ -17,7 +17,6 @@
package org.opensaml.core.xml;
-import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
@@ -26,6 +25,10 @@ import javax.xml.namespace.QName;
import org.opensaml.core.xml.util.IndexedXMLObjectChildrenList;
+import net.shibboleth.shared.annotation.constraint.NotLive;
+import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
+
/**
* AbstractElementExtensible is an element of type <code>xs:any</code>, but without <code>xs:anyAttribute</code>
* attribute or text content.
@@ -50,8 +53,8 @@ public abstract class AbstractElementExtensibleXMLObject extends AbstractXMLObje
}
/** {@inheritDoc} */
- @Nullable public List<XMLObject> getOrderedChildren() {
- return Collections.unmodifiableList(anyXMLObjects);
+ @Nullable @Unmodifiable @NotLive public List<XMLObject> getOrderedChildren() {
+ return CollectionSupport.copyToList(anyXMLObjects);
}
/** {@inheritDoc} */
diff --git a/opensaml-core-api/src/main/java/org/opensaml/core/xml/AbstractExtensibleXMLObjectMarshaller.java b/opensaml-core-api/src/main/java/org/opensaml/core/xml/AbstractExtensibleXMLObjectMarshaller.java
index f58bdb233..f49d8c86e 100644
--- a/opensaml-core-api/src/main/java/org/opensaml/core/xml/AbstractExtensibleXMLObjectMarshaller.java
+++ b/opensaml-core-api/src/main/java/org/opensaml/core/xml/AbstractExtensibleXMLObjectMarshaller.java
@@ -49,7 +49,7 @@ public abstract class AbstractExtensibleXMLObjectMarshaller extends AbstractElem
}
/** {@inheritDoc} */
- protected void marshallAttributeIDness(final XMLObject xmlObject, final Element domElement)
+ protected void marshallAttributeIDness(@Nonnull final XMLObject xmlObject, @Nonnull final Element domElement)
throws MarshallingException {
final AttributeExtensibleXMLObject anyAttribute = (AttributeExtensibleXMLObject) xmlObject;
diff --git a/opensaml-core-api/src/main/java/org/opensaml/core/xml/NamespaceManager.java b/opensaml-core-api/src/main/java/org/opensaml/core/xml/NamespaceManager.java
index 3d2840908..778466b16 100644
--- a/opensaml-core-api/src/main/java/org/opensaml/core/xml/NamespaceManager.java
+++ b/opensaml-core-api/src/main/java/org/opensaml/core/xml/NamespaceManager.java
@@ -18,7 +18,6 @@
package org.opensaml.core.xml;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -27,7 +26,11 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.xml.namespace.QName;
+import net.shibboleth.shared.annotation.constraint.NonnullElements;
import net.shibboleth.shared.annotation.constraint.NotEmpty;
+import net.shibboleth.shared.annotation.constraint.NotLive;
+import net.shibboleth.shared.annotation.constraint.Unmodifiable;
+import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.collection.LazyMap;
import net.shibboleth.shared.collection.LazySet;
import net.shibboleth.shared.logic.Constraint;
@@ -47,24 +50,24 @@ import com.google.common.base.Strings;
public class NamespaceManager {
/** The token used to represent the default namespace in {@link #getNonVisibleNamespacePrefixes()}. */
- public static final String DEFAULT_NS_TOKEN = "#default";
+ @Nonnull @NotEmpty public static final String DEFAULT_NS_TOKEN = "#default";
/** The 'xml' namespace. */
- private static final Namespace XML_NAMESPACE =
+ @Nonnull private static final Namespace XML_NAMESPACE =
new Namespace(XMLConstants.XML_NS, XMLConstants.XML_PREFIX);
/** The 'xsi' namespace. */
- private static final Namespace XSI_NAMESPACE =
+ @Nonnull private static final Namespace XSI_NAMESPACE =
new Namespace(XMLConstants.XSI_NS, XMLConstants.XSI_PREFIX);
/** The owning XMLObject. */
@Nonnull private final XMLObject owner;
/** XMLObject name namespace. */
- private Namespace elementName;
+ @Nullable private Namespace elementName;
/** XMLObject type namespace. */
- private Namespace elementType;
+ @Nullable private Namespace elementType;
/** Explicitly declared namespaces. */
@Nonnull private final Set<Namespace> decls;
@@ -117,12 +120,12 @@ public class NamespaceManager {
*
* @return the unmodifiable set of namespaces
*/
- @Nonnull public Set<Namespace> getNamespaces() {
+ @Nonnull @NonnullElements @Unmodifiable @NotLive public Set<Namespace> getNamespaces() {
final Set<Namespace> namespaces = mergeNamespaceCollections(decls, attrNames, attrValues.values());
addNamespace(namespaces, getElementNameNamespace());
addNamespace(namespaces, getElementTypeNamespace());
addNamespace(namespaces, contentValue);
- return Collections.unmodifiableSet(namespaces);
+ return CollectionSupport.copyToSet(namespaces);
}
/**
@@ -148,8 +151,8 @@ public class NamespaceManager {
*
* @return the set of namespace declarations
*/
- @Nonnull public Set<Namespace> getNamespaceDeclarations() {
- return Collections.unmodifiableSet(decls);
+ @Nonnull @NonnullElements @Unmodifiable @NotLive public Set<Namespace> getNamespaceDeclarations() {
+ return CollectionSupport.copyToSet(decls);
}
/**
@@ -405,6 +408,7 @@ public class NamespaceManager {
* @param namespaces list of Namespaces to merge
* @return the a new set of merged Namespaces
*/
+ @SafeVarargs
@Nonnull private Set<Namespace> mergeNamespaceCollections(final Collection<Namespace> ... namespaces) {
final LazySet<Namespace> newNamespaces = new LazySet<>();
diff --git a/opensaml-core-api/src/main/java/org/opensaml/core/xml/XMLObject.java b/opensaml-core-api/src/main/java/org/opensaml/core/xml/XMLObject.java
index f7a9a2103..901ee623c 100644
--- a/opensaml-core-api/src/main/java/org/opensaml/core/xml/XMLObject.java
+++ b/opensaml-core-api/src/main/java/org/opensaml/core/xml/XMLObject.java
@@ -28,6 +28,8 @@ import org.opensaml.core.xml.schema.XSBooleanValue;
import org.opensaml.core.xml.util.IDIndex;
import org.w3c.dom.Element;
+import net.shibboleth.shared.annotation.constraint.NotLive;
+import net.shibboleth.shared.annotation.constraint.Unmodifiable;
import net.shibboleth.shared.collection.LockableClassToInstanceMultiMap;
/**
@@ -92,7 +94,7 @@ public interface XMLObject {
*
* @return ordered list of child elements
*/
- @Nullable public List<XMLObject> getOrderedChildren();
+ @Nullable @Unmodifiable @NotLive public List<XMLObject> getOrderedChildren();
/**
* Gets the parent of this element or null if there is no parent.
@@ -283,7 +285,6 @@ public interface XMLObject {
*/
public void setNil(@Nullable final XSBooleanValue newNil);
-
/**
* Get the mutable multimap which holds additional information (represented by plain Java object instances)
* associated with this XMLObject.
diff --git a/opensaml-core-api/src/main/java/org/opensaml/core/xml/XMLObjectBuilderFactory.java b/opensaml-core-api/src/main/java/org/opensaml/core/xml/XMLObjectBuilderFactory.java
index 54bfabd4c..8b6230f8f 100644
--- a/opensaml-core-api/src/main/java/org/opensaml/core/xml/XMLObjectBuilderFactory.java
+++ b/opensaml-core-api/src/main/java/org/opensaml/core/xml/XMLObjectBuilderFactory.java
@@ -28,11 +28,12 @@ import net.shibboleth.shared.annotation.constraint.NotLive;
import net.shibboleth.shared.annotation.constraint.Unmodifiable;
import net.shibboleth.shared.collection.CollectionSupport;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.xml.DOMTypeSupport;
import net.shibboleth.shared.xml.QNameSupport;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+
import org.w3c.dom.Element;
/**
diff --git a/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/AttributeMap.java b/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/AttributeMap.java
index 6cfc4f05a..1fa01d29c 100644
--- a/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/AttributeMap.java
+++ b/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/AttributeMap.java
@@ -24,12 +24,14 @@ import java.util.Objects;
import java.util.Set;
import javax.annotation.Nonnull;
+import javax.annotation.Nullable;
import javax.annotation.concurrent.NotThreadSafe;
import javax.xml.namespace.QName;
import net.shibboleth.shared.collection.LazyMap;
import net.shibboleth.shared.collection.LazySet;
import net.shibboleth.shared.logic.Constraint;
+import net.shibboleth.shared.primitive.LoggerFactory;
import net.shibboleth.shared.primitive.StringSupport;
import net.shibboleth.shared.xml.QNameSupport;
@@ -37,7 +39,6 @@ import org.opensaml.core.xml.NamespaceManager;
import org.opensaml.core.xml.XMLObject;
import org.opensaml.core.xml.config.XMLObjectProviderRegistrySupport;
import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import com.google.common.base.Strings;
@@ -49,21 +50,21 @@ import com.google.common.base.Strings;
public class AttributeMap implements Map<QName, String> {
/** Logger. */
- private final Logger log = LoggerFactory.getLogger(AttributeMap.class);
+ @Nonnull private final Logger log = LoggerFactory.getLogger(AttributeMap.class);
/** XMLObject owning the attributes. */
- private final XMLObject attributeOwner;
+ @Nonnull private final XMLObject attributeOwner;
/** Map of attributes. */
- private Map<QName, String> attributes;
+ @Nonnull private Map<QName, String> attributes;
/** Set of attribute QNames which have been locally registered as having an ID type within this
* AttributeMap instance. */
- private Set<QName> idAttribNames;
+ @Nonnull private Set<QName> idAttribNames;
/** Set of attribute QNames which have been locally registered as having an QName value type within this
* AttributeMap instance. */
- private Set<QName> qnameAttribNames;
+ @Nonnull private Set<QName> qnameAttribNames;
/** Flag indicating whether an attempt should be made to infer QName values,
* if attribute is not registered as a QName type. */
@@ -235,7 +236,7 @@ public class AttributeMap implements Map<QName, String> {
*
* @param attributeName the QName of the ID attribute to be registered
*/
- public void registerID(final QName attributeName) {
+ public void registerID(@Nonnull final QName attributeName) {
if (! idAttribNames.contains(attributeName)) {
idAttribNames.add(attributeName);
}
@@ -252,7 +253,7 @@ public class AttributeMap implements Map<QName, String> {
*
* @param attributeName the QName of the ID attribute to be de-registered
*/
- public void deregisterID(final QName attributeName) {
+ public void deregisterID(@Nonnull final QName attributeName) {
if (idAttribNames.contains(attributeName)) {
idAttribNames.remove(attributeName);
}
@@ -271,7 +272,7 @@ public class AttributeMap implements Map<QName, String> {
* @param attributeName the QName of the attribute to be checked for ID type.
* @return true if attribute is registered as having an ID type.
*/
- public boolean isIDAttribute(final QName attributeName) {
+ public boolean isIDAttribute(@Nonnull final QName attributeName) {
return idAttribNames.contains(attributeName);
}
@@ -280,7 +281,7 @@ public class AttributeMap implements Map<QName, String> {
*
* @param attributeName the name of the QName-valued attribute to be registered
*/
- public void registerQNameAttribute(final QName attributeName) {
+ public void registerQNameAttribute(@Nonnull final QName attributeName) {
qnameAttribNames.add(attributeName);
}
@@ -289,7 +290,7 @@ public class AttributeMap implements Map<QName, String> {
*
* @param attributeName the name of the QName-valued attribute to be registered
*/
- public void deregisterQNameAttribute(final QName attributeName) {
+ public void deregisterQNameAttribute(@Nonnull final QName attributeName) {
qnameAttribNames.remove(attributeName);
}
@@ -299,7 +300,7 @@ public class AttributeMap implements Map<QName, String> {
* @param attributeName the QName of the attribute to be checked for QName type.
* @return true if attribute is registered as having an QName type.
*/
- public boolean isQNameAttribute(final QName attributeName) {
+ public boolean isQNameAttribute(@Nonnull final QName attributeName) {
return qnameAttribNames.contains(attributeName);
}
@@ -340,7 +341,7 @@ public class AttributeMap implements Map<QName, String> {
* @param attributeName the attribute name
* @param attributeValue the attribute value
*/
- private void checkAndRegisterQNameValue(final QName attributeName, final String attributeValue) {
+ private void checkAndRegisterQNameValue(@Nonnull final QName attributeName, @Nullable final String attributeValue) {
if (attributeValue == null) {
return;
}
@@ -363,10 +364,7 @@ public class AttributeMap implements Map<QName, String> {
* @param attributeName the attribute name
* @param attributeValue the attribute value
*/
- private void registerQNameValue(final QName attributeName, final QName attributeValue) {
- if (attributeValue == null) {
- return;
- }
+ private void registerQNameValue(@Nonnull final QName attributeName, @Nonnull final QName attributeValue) {
final String attributeID = NamespaceManager.generateAttributeID(attributeName);
log.trace("Registering QName attribute value '{}' under attibute ID '{}'",
@@ -381,7 +379,8 @@ public class AttributeMap implements Map<QName, String> {
* @param attributeName the attribute name
* @param attributeValue the attribute value
*/
- private void checkAndDeregisterQNameValue(final QName attributeName, final String attributeValue) {
+ private void checkAndDeregisterQNameValue(@Nonnull final QName attributeName,
+ @Nullable final String attributeValue) {
if (attributeValue == null) {
return;
}
@@ -402,7 +401,7 @@ public class AttributeMap implements Map<QName, String> {
*
* @param attributeName the attribute name whose QName attribute value should be deregistered
*/
- private void deregisterQNameValue(final QName attributeName) {
+ private void deregisterQNameValue(@Nonnull final QName attributeName) {
final String attributeID = NamespaceManager.generateAttributeID(attributeName);
log.trace("Deregistering QName attribute with attibute ID '{}'", attributeID);
attributeOwner.getNamespaceManager().deregisterAttributeValue(attributeID);
@@ -415,7 +414,7 @@ public class AttributeMap implements Map<QName, String> {
* @param attributeValue the attribute value
* @return the QName if the attribute value is a QName type, otherwise null
*/
- private QName checkQName(final QName attributeName, final String attributeValue) {
+ private QName checkQName(@Nonnull final QName attributeName, @Nullable final String attributeValue) {
log.trace("Checking whether attribute '{}' with value {} is a QName type", attributeName, attributeValue);
if (attributeValue == null) {
@@ -461,7 +460,7 @@ public class AttributeMap implements Map<QName, String> {
*
* @return the QName, or null if unable to resolve into a QName
*/
- private QName resolveQName(final String attributeValue, final boolean isDefaultNSOK) {
+ private QName resolveQName(@Nullable final String attributeValue, final boolean isDefaultNSOK) {
if (attributeValue == null) {
return null;
}
@@ -510,7 +509,7 @@ public class AttributeMap implements Map<QName, String> {
* @param attributeValue the QName to process
* @return the attribute value string representation of the QName
*/
- private String constructAttributeValue(final QName attributeValue) {
+ private String constructAttributeValue(@Nonnull final QName attributeValue) {
final String trimmedLocalName = StringSupport.trimOrNull(attributeValue.getLocalPart());
if (trimmedLocalName == null) {
diff --git a/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/IndexedXMLObjectChildrenList.java b/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/IndexedXMLObjectChildrenList.java
index 26cf7daf9..f67423192 100644
--- a/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/IndexedXMLObjectChildrenList.java
+++ b/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/IndexedXMLObjectChildrenList.java
@@ -45,7 +45,7 @@ import com.google.common.collect.Collections2;
public class IndexedXMLObjectChildrenList<ElementType extends XMLObject> extends XMLObjectChildrenList<ElementType> {
/** Index of objects by type and name. */
- private final Map<QName, List<ElementType>> objectIndex;
+ @Nonnull private final Map<QName, List<ElementType>> objectIndex;
/**
* Constructor.
diff --git a/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/XMLObjectChildrenList.java b/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/XMLObjectChildrenList.java
index a5405d88e..338f26e7d 100644
--- a/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/XMLObjectChildrenList.java
+++ b/opensaml-core-api/src/main/java/org/opensaml/core/xml/util/XMLObjectChildrenList.java
@@ -42,10 +42,10 @@ import com.google.common.collect.Collections2;
public class XMLObjectChildrenList<ElementType extends XMLObject> extends AbstractList<ElementType> {
/** Parent to the elements in this list. */
- private final XMLObject parent;
+ @Nonnull private final XMLObject parent;
/** List of elements. */
- private final List<ElementType> elements;
+ @Nonnull private final List<ElementType> elements;
/**
* Constructs an empty list with all added XMLObjects being assigned the given parent XMLObject.
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list