[java-metadata-aggregator] branch master updated: MDA-222 - collection properties contracts
Ian Young
ian at iay.org.uk
Thu Mar 12 06:07:28 EDT 2020
This is an automated email from the git hooks/post-receive script.
iay pushed a commit to branch master
in repository java-metadata-aggregator.
View the commit online:
http://git.shibboleth.net/view/?p=java-metadata-aggregator.git;a=commit;h=74f036df401a8f4a0a486659fde748b59cb0eb00
The following commit(s) were added to refs/heads/master by this push:
new 74f036d MDA-222 - collection properties contracts
74f036d is described below
commit 74f036df401a8f4a0a486659fde748b59cb0eb00
Author: Ian Young <ian at iay.org.uk>
AuthorDate: Thu Sep 26 17:49:39 2019 +0100
MDA-222 - collection properties contracts
https://issues.shibboleth.net/jira/browse/MDA-222
---
.../metadata/dom/AbstractDOMValidationStage.java | 8 ++-
.../metadata/dom/AbstractElementVisitingStage.java | 16 +++--
.../metadata/dom/AbstractXSLProcessingStage.java | 75 +++++++---------------
.../metadata/dom/ElementsStrippingStage.java | 14 ++--
.../metadata/dom/NamespacesStrippingStage.java | 29 ++++++---
.../metadata/dom/XMLSchemaValidationStage.java | 19 +++---
.../metadata/dom/XMLSignatureSigningStage.java | 33 ++++------
.../metadata/dom/XMLSignatureValidationStage.java | 38 ++++++-----
.../dom/saml/ContactPersonFilterStage.java | 51 ++++++---------
.../metadata/dom/saml/EntityFilterStage.java | 38 +++++------
.../metadata/dom/saml/EntityRoleFilterStage.java | 43 +++++--------
.../saml/mdattr/EntityAttributeFilteringStage.java | 15 +++--
.../EntityRegistrationAuthorityFilterStage.java | 30 ++++-----
...trationAuthorityItemIdentificationStrategy.java | 34 +++++-----
.../AbstractItemMetadataSelectionStage.java | 43 ++++++-------
.../metadata/pipeline/CompositeStage.java | 48 ++++----------
.../metadata/pipeline/ItemIdTransformStage.java | 13 ++--
.../metadata/pipeline/ItemMetadataAddingStage.java | 15 +++--
.../net/shibboleth/metadata/pipeline/Pipeline.java | 8 ++-
.../pipeline/PipelineDemultiplexerStage.java | 42 +++++-------
.../metadata/pipeline/PipelineMergeStage.java | 39 +++++------
.../metadata/pipeline/SimplePipeline.java | 18 ++----
.../metadata/pipeline/StaticItemSourceStage.java | 33 ++++------
.../metadata/validate/ValidatorSequence.java | 19 +++---
.../dom/saml/ContactPersonFilterStageTest.java | 12 ++--
25 files changed, 308 insertions(+), 425 deletions(-)
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractDOMValidationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractDOMValidationStage.java
index 5f8a044..447213d 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractDOMValidationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractDOMValidationStage.java
@@ -24,6 +24,8 @@ import javax.annotation.Nonnull;
import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.metadata.validate.Validator;
import net.shibboleth.metadata.validate.ValidatorSequence;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
/**
@@ -36,7 +38,7 @@ public abstract class AbstractDOMValidationStage<V, C extends DOMTraversalContex
extends AbstractDOMTraversalStage<C> {
/** The validator sequence to apply. */
- @Nonnull
+ @Nonnull @NonnullElements @Unmodifiable
private ValidatorSequence<V> validators = new ValidatorSequence<>();
/**
@@ -44,7 +46,7 @@ public abstract class AbstractDOMValidationStage<V, C extends DOMTraversalContex
*
* @param newValidators the list of validators to set
*/
- public void setValidators(@Nonnull final List<Validator<V>> newValidators) {
+ public void setValidators(@Nonnull @NonnullElements @Unmodifiable final List<Validator<V>> newValidators) {
validators.setValidators(newValidators);
}
@@ -53,7 +55,7 @@ public abstract class AbstractDOMValidationStage<V, C extends DOMTraversalContex
*
* @return list of validators
*/
- @Nonnull
+ @Nonnull @NonnullElements @Unmodifiable
public List<Validator<V>> getValidators() {
return validators.getValidators();
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractElementVisitingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractElementVisitingStage.java
index b390270..b3b663a 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractElementVisitingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractElementVisitingStage.java
@@ -18,8 +18,6 @@
package net.shibboleth.metadata.dom;
import java.util.Collection;
-import java.util.Collections;
-import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nonnull;
@@ -28,6 +26,8 @@ import javax.xml.namespace.QName;
import org.w3c.dom.Element;
import net.shibboleth.metadata.Item;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -38,7 +38,8 @@ import net.shibboleth.utilities.java.support.logic.Constraint;
public abstract class AbstractElementVisitingStage extends AbstractDOMTraversalStage<DOMTraversalContext> {
/** Collection of element names for those elements we will be visiting. */
- @Nonnull private Set<QName> elementNames = Collections.emptySet();
+ @Nonnull @NonnullElements @Unmodifiable
+ private Set<QName> elementNames = Set.of();
@Override
protected void doDestroy() {
@@ -52,7 +53,8 @@ public abstract class AbstractElementVisitingStage extends AbstractDOMTraversalS
*
* @return collection of element names to visit.
*/
- @Nonnull public Collection<QName> getElementNames() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public Collection<QName> getElementNames() {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
return elementNames;
}
@@ -62,11 +64,11 @@ public abstract class AbstractElementVisitingStage extends AbstractDOMTraversalS
*
* @param names collection of element names to visit.
*/
- public void setElementNames(@Nonnull final Collection<QName> names) {
+ public void setElementNames(@Nonnull @NonnullElements @Unmodifiable final Collection<QName> names) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
Constraint.isNotNull(names, "elementNames may not be null");
- elementNames = new HashSet<>(names);
+ elementNames = Set.copyOf(names);
}
/**
@@ -80,7 +82,7 @@ public abstract class AbstractElementVisitingStage extends AbstractDOMTraversalS
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
Constraint.isNotNull(name, "elementName may not be null");
- elementNames = Collections.singleton(name);
+ elementNames = Set.of(name);
}
@Override
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java
index 1df70de..9b09dd8 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/AbstractXSLProcessingStage.java
@@ -19,8 +19,6 @@ package net.shibboleth.metadata.dom;
import java.io.IOException;
import java.util.Collection;
-import java.util.Collections;
-import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
@@ -43,7 +41,6 @@ import net.shibboleth.metadata.WarningStatus;
import net.shibboleth.metadata.pipeline.AbstractStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
@@ -77,17 +74,20 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
private Templates xslTemplate;
/** Attributes set on the {@link Transformer} used by this stage. */
- private Map<String, Object> transformAttributes = Collections.emptyMap();
+ @Nonnull @NonnullElements @Unmodifiable
+ private Map<String, Object> transformAttributes = Map.of();
/** Features set on the {@link Transformer} used by this stage. */
- private Map<String, Boolean> transformFeatures = Collections.emptyMap();
+ @Nonnull @NonnullElements @Unmodifiable
+ private Map<String, Boolean> transformFeatures = Map.of();
/**
* Collection of named parameters to make available to the transform.
*
* If not set, an empty collection.
*/
- private Map<String, Object> transformParameters = Collections.emptyMap();
+ @Nonnull @NonnullElements @Unmodifiable
+ private Map<String, Object> transformParameters = Map.of();
/** {@link URIResolver} to use in the transformer. Default value: <code>null</code>. */
@Nullable private URIResolver uriResolver;
@@ -118,7 +118,8 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
*
* @return unmodifiable collection of attributes used by the XSLT transformer, never null nor containing null keys
*/
- @Nonnull @NonnullElements @Unmodifiable public Map<String, Object> getTransformAttributes() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public Map<String, Object> getTransformAttributes() {
return transformAttributes;
}
@@ -127,22 +128,12 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
*
* @param attributes collection of attributes used by the XSLT transformer, may be null or contain null keys
*/
- public synchronized void setTransformAttributes(@Nullable @NullableElements final Map<String, Object> attributes) {
+ public synchronized void setTransformAttributes(
+ @Nonnull @NonnullElements @Unmodifiable final Map<String, Object> attributes) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (attributes == null || attributes.isEmpty()) {
- transformAttributes = Collections.emptyMap();
- }
-
- final HashMap<String, Object> newAttributes = new HashMap<>();
- for (final String attributeName : attributes.keySet()) {
- if (attributeName != null) {
- newAttributes.put(attributeName, attributes.get(attributeName));
- }
- }
-
- transformAttributes = Collections.unmodifiableMap(newAttributes);
+ transformAttributes = Map.copyOf(attributes);
}
/**
@@ -150,7 +141,8 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
*
* @return unmodifiable collection of features used by the XSLT transformer, never null nor containing null keys
*/
- @Nonnull @NonnullElements @Unmodifiable public Map<String, Boolean> getTransformFeatures() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public Map<String, Boolean> getTransformFeatures() {
return transformFeatures;
}
@@ -159,22 +151,12 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
*
* @param features collection of features used by the XSLT transformer, may be null or contain null keys
*/
- public synchronized void setTransformFeatures(@Nullable @NullableElements final Map<String, Boolean> features) {
+ public synchronized void setTransformFeatures(
+ @Nonnull @NonnullElements @Unmodifiable final Map<String, Boolean> features) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (features == null || features.isEmpty()) {
- transformFeatures = Collections.emptyMap();
- }
-
- final HashMap<String, Boolean> newFeatures = new HashMap<>();
- for (final String featuresName : features.keySet()) {
- if (featuresName != null) {
- newFeatures.put(featuresName, features.get(featuresName));
- }
- }
-
- transformFeatures = Collections.unmodifiableMap(newFeatures);
+ transformFeatures = Map.copyOf(features);
}
/**
@@ -182,7 +164,8 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
*
* @return parameters used by the XSLT transformer, never null nor containing null keys
*/
- @Nonnull @NonnullElements @Unmodifiable public Map<String, Object> getTransformParameters() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public Map<String, Object> getTransformParameters() {
return transformParameters;
}
@@ -191,23 +174,12 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
*
* @param parameters parameters for the transform, may be null or contain null keys
*/
- public synchronized void setTransformParameters(@Nullable @NullableElements final Map<String, Object> parameters) {
+ public synchronized void setTransformParameters(
+ @Nonnull @NonnullElements @Unmodifiable final Map<String, Object> parameters) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (parameters == null) {
- transformParameters = Collections.emptyMap();
- return;
- }
-
- final HashMap<String, Object> newParams = new HashMap<>();
- for (final String paramName : parameters.keySet()) {
- if (paramName != null) {
- newParams.put(paramName, parameters.get(paramName));
- }
- }
-
- transformParameters = Collections.unmodifiableMap(newParams);
+ transformParameters = Map.copyOf(parameters);
}
/**
@@ -259,9 +231,8 @@ public abstract class AbstractXSLProcessingStage extends AbstractStage<Element>
@Nonnull @NonnullElements final Collection<Item<Element>> itemCollection) throws StageProcessingException,
TransformerConfigurationException;
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
-
+ @Override
+ protected void doDestroy() {
xslResource = null;
xslTemplate = null;
transformAttributes = null;
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java
index 22a8d7a..b9f7ebc 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/ElementsStrippingStage.java
@@ -19,7 +19,6 @@ package net.shibboleth.metadata.dom;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.HashSet;
import java.util.List;
import java.util.Set;
@@ -30,7 +29,9 @@ import javax.annotation.concurrent.ThreadSafe;
import org.w3c.dom.Element;
import net.shibboleth.metadata.Item;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
import net.shibboleth.utilities.java.support.annotation.constraint.NotEmpty;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -95,7 +96,8 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
private String elementNamespace;
/** Names of the elements to strip. */
- private Set<String> elementNames = new HashSet<>();
+ @Nonnull @NonnullElements @Unmodifiable
+ private Set<String> elementNames = Set.of();
/** Whether we are operating in a whitelisting mode (<code>false</code> by default). */
private boolean whitelisting;
@@ -127,7 +129,8 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
*
* @return the names of the elements to strip
*/
- @Nullable public Collection<String> getElementNames() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public Collection<String> getElementNames() {
return elementNames;
}
@@ -136,11 +139,12 @@ public class ElementsStrippingStage extends AbstractDOMTraversalStage<ElementsSt
*
* @param names the names of the elements to strip
*/
- public void setElementNames(@Nonnull @NotEmpty final Collection<String> names) {
+ public void setElementNames(
+ @Nonnull @NonnullElements @Unmodifiable @NotEmpty final Collection<String> names) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- elementNames = new HashSet<String>(names);
+ elementNames = Set.copyOf(names);
}
/**
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java
index 998f3b8..2db8d7b 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/NamespacesStrippingStage.java
@@ -18,12 +18,13 @@
package net.shibboleth.metadata.dom;
import java.util.Collection;
-import java.util.HashSet;
import java.util.Set;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
/**
@@ -35,6 +36,10 @@ import net.shibboleth.utilities.java.support.component.ComponentSupport;
* or retained depending on the {@link #whitelisting} property.
*
* Attributes without an explicit namespace prefix will never be removed by this stage.
+ *
+ * Note that because the collection is specified as <code>@NonnullElements</code>, this stage can not
+ * be used in blacklisting mode to remove elements in the default namespace. It will always remove
+ * elements in the default namespace if used in the whitelisting mode.
*/
@ThreadSafe
public class NamespacesStrippingStage extends AbstractNamespacesStrippingStage {
@@ -42,7 +47,8 @@ public class NamespacesStrippingStage extends AbstractNamespacesStrippingStage {
/**
* XML namespaces to whitelist or blacklist.
*/
- private final Set<String> namespaces = new HashSet<>();
+ @Nonnull @NonnullElements @Unmodifiable
+ private Set<String> namespaces = Set.of();
/**
* Whether we are whitelisting or blacklisting (default: blacklisting).
@@ -54,11 +60,9 @@ public class NamespacesStrippingStage extends AbstractNamespacesStrippingStage {
*
* @return collection of namespaces being removed
*/
- @Nonnull
+ @Nonnull @NonnullElements @Unmodifiable
public Collection<String> getNamespaces() {
- final Set<String> result = new HashSet<>();
- result.addAll(namespaces);
- return result;
+ return namespaces;
}
/**
@@ -66,12 +70,11 @@ public class NamespacesStrippingStage extends AbstractNamespacesStrippingStage {
*
* @param nss collection of namespaces
*/
- public void setNamespaces(@Nonnull final Collection<String> nss) {
+ public void setNamespaces(@Nonnull @NonnullElements @Unmodifiable final Collection<String> nss) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- namespaces.clear();
- namespaces.addAll(nss);
+ namespaces = Set.copyOf(nss);
}
/**
@@ -97,12 +100,18 @@ public class NamespacesStrippingStage extends AbstractNamespacesStrippingStage {
@Override
protected boolean removingNamespace(final String namespace) {
+ // Handle ineligible null element, for the default namespace case
+ if (namespace == null) {
+ return whitelisting;
+ }
+
+ // Handle normal namespaces
return whitelisting ^ namespaces.contains(namespace);
}
@Override
protected void doDestroy() {
- namespaces.clear();
+ namespaces = null;
super.doDestroy();
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSchemaValidationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSchemaValidationStage.java
index 54c0bdb..843aede 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSchemaValidationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSchemaValidationStage.java
@@ -18,7 +18,6 @@
package net.shibboleth.metadata.dom;
import java.io.IOException;
-import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
@@ -35,17 +34,12 @@ import org.springframework.core.io.Resource;
import org.w3c.dom.Element;
import org.xml.sax.SAXException;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
import net.shibboleth.metadata.ErrorStatus;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.WarningStatus;
import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
@@ -72,7 +66,8 @@ public class XMLSchemaValidationStage extends AbstractIteratingStage<Element> {
private final Logger log = LoggerFactory.getLogger(XMLSchemaValidationStage.class);
/** Collection of schema resources. */
- private List<Resource> schemaResources = Collections.emptyList();
+ @Nonnull @NonnullElements @Unmodifiable
+ private List<Resource> schemaResources = List.of();
/** Whether Elements are required to be schema valid. Default value: <code>true</code> */
private boolean elementRequiredToBeSchemaValid = true;
@@ -85,7 +80,8 @@ public class XMLSchemaValidationStage extends AbstractIteratingStage<Element> {
*
* @return unmodifiable list of schema resources against which Elements are validated
*/
- @Nonnull @NonnullElements @Unmodifiable public List<Resource> getSchemaResources() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public List<Resource> getSchemaResources() {
return schemaResources;
}
@@ -94,11 +90,12 @@ public class XMLSchemaValidationStage extends AbstractIteratingStage<Element> {
*
* @param resources schema resources against which Elements are validated
*/
- public synchronized void setSchemaResources(@Nullable @NullableElements final List<Resource> resources) {
+ public synchronized void setSchemaResources(
+ @Nullable @NonnullElements @Unmodifiable final List<Resource> resources) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- schemaResources = ImmutableList.copyOf(Iterables.filter(resources, Predicates.notNull()));
+ schemaResources = List.copyOf(resources);
}
/**
@@ -153,7 +150,7 @@ public class XMLSchemaValidationStage extends AbstractIteratingStage<Element> {
@Override protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
- if (schemaResources == null || schemaResources.isEmpty()) {
+ if (schemaResources.isEmpty()) {
throw new ComponentInitializationException("Unable to initialize " + getId()
+ ", SchemaResources may not be empty");
}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureSigningStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureSigningStage.java
index fd7abdb..24549cd 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureSigningStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureSigningStage.java
@@ -120,10 +120,11 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
* Certificate chain, with end entity certificate as element 0, to be included with the signature. Default value:
* empty list
*/
- private List<X509Certificate> certificates;
+ @Nonnull @NonnullElements @Unmodifiable
+ private List<X509Certificate> certificates = List.of();
/** CRLs to be included with the signature. Default value: empty list */
- private List<X509CRL> crls;
+ private List<X509CRL> crls = Collections.emptyList();
/** Signature algorithm used. */
private String sigAlgo;
@@ -147,7 +148,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
private String c14nAlgo;
/** Inclusive prefix list used with exclusive canonicalization. Default value: empty list */
- private List<String> inclusivePrefixList;
+ private List<String> inclusivePrefixList = Collections.emptyList();
/**
* Names of attributes to treat as ID attributes for signature referencing. Default value: list containing the
@@ -156,7 +157,7 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
private List<QName> idAttributeNames;
/** Explicit names to associate with the given signing key. Default value: empty list */
- private List<String> keyNames;
+ private List<String> keyNames = Collections.emptyList();
/** Whether key names should be included in the signature's KeyInfo. Default value: <code>true</code> */
private boolean includeKeyNames;
@@ -199,12 +200,8 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
*/
public XMLSignatureSigningStage() {
shaVariant = ShaVariant.SHA256;
- certificates = Collections.emptyList();
- crls = Collections.emptyList();
c14nExclusive = true;
- inclusivePrefixList = Collections.emptyList();
idAttributeNames = Arrays.asList(new QName[]{new QName("ID"), new QName("id"), new QName("Id")});
- keyNames = Collections.emptyList();
includeKeyNames = true;
includeX509Certificates = true;
}
@@ -278,7 +275,8 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
*
* @return certificates associated with the key used to sign the content
*/
- @Nonnull @NonnullElements @Unmodifiable public List<X509Certificate> getCertificates() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public List<X509Certificate> getCertificates() {
return certificates;
}
@@ -288,15 +286,12 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
*
* @param certs certificates associated with the key used to sign the content
*/
- public synchronized void setCertificates(@Nullable @NullableElements final List<X509Certificate> certs) {
+ public synchronized void setCertificates(
+ @Nonnull @NonnullElements @Unmodifiable final List<X509Certificate> certs) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (certs == null || certs.isEmpty()) {
- certificates = Collections.emptyList();
- } else {
- certificates = ImmutableList.copyOf(Iterables.filter(certs, Predicates.notNull()));
- }
+ certificates = List.copyOf(certs);
}
/**
@@ -918,8 +913,8 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
}
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ @Override
+ protected void doDestroy() {
xmlSigFactory = null;
keyInfoFactory = null;
privKey = null;
@@ -936,8 +931,8 @@ public class XMLSignatureSigningStage extends AbstractIteratingStage<Element> {
super.doDestroy();
}
- /** {@inheritDoc} */
- @Override protected void doInitialize() throws ComponentInitializationException {
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
if (!Init.isInitialized()) {
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureValidationStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureValidationStage.java
index 320b947..225995a 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureValidationStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/XMLSignatureValidationStage.java
@@ -20,7 +20,6 @@ package net.shibboleth.metadata.dom;
import java.security.PublicKey;
import java.security.cert.Certificate;
import java.util.Collection;
-import java.util.Collections;
import java.util.Set;
import javax.annotation.Nonnull;
@@ -32,8 +31,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
-import com.google.common.collect.ImmutableSet;
-
import net.shibboleth.metadata.ErrorStatus;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.WarningStatus;
@@ -41,6 +38,7 @@ import net.shibboleth.metadata.dom.XMLSignatureValidator.ValidationException;
import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -81,10 +79,10 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
private PublicKey verificationKey;
/** Set of blacklisted digest URIs. Default value: empty set. */
- @Nonnull private Set<String> blacklistedDigests = Collections.emptySet();
+ @Nonnull @NonnullElements private Set<String> blacklistedDigests = Set.of();
/** Set of blacklisted signature method URIs. Default value: empty set. */
- @Nonnull private Set<String> blacklistedSignatureMethods = Collections.emptySet();
+ @Nonnull @NonnullElements private Set<String> blacklistedSignatureMethods = Set.of();
/** Option to determine whether empty references are to be permitted. Default value: <code>true</code>. */
private boolean permittingEmptyReferences = true;
@@ -183,12 +181,11 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
*
* @param identifiers collection of identifiers to be blacklisted
*/
- public void setBlacklistedDigests(@Nonnull @NonnullElements final Collection<String> identifiers) {
+ public void setBlacklistedDigests(@Nonnull @NonnullElements @Unmodifiable final Collection<String> identifiers) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
-
- blacklistedDigests = ImmutableSet.copyOf(Constraint.isNotNull(identifiers,
- "identifier collection may not be null"));
+
+ blacklistedDigests = Set.copyOf(identifiers);
}
/**
@@ -196,8 +193,8 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
*
* @return the set of blacklisted digest algorithm identifiers
*/
- @Nonnull @NonnullElements public Set<String> getBlacklistedDigests() {
- return Collections.unmodifiableSet(blacklistedDigests);
+ @Nonnull @NonnullElements @Unmodifiable public Set<String> getBlacklistedDigests() {
+ return blacklistedDigests;
}
/**
@@ -205,11 +202,12 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
*
* @param identifiers collection of identifiers to be blacklisted
*/
- public void setBlacklistedSignatureMethods(@Nonnull @NonnullElements final Collection<String> identifiers) {
+ public void setBlacklistedSignatureMethods(
+ @Nonnull @NonnullElements @Unmodifiable final Collection<String> identifiers) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- blacklistedSignatureMethods = ImmutableSet.copyOf(Constraint.isNotNull(identifiers,
- "identifier collection may not be null"));
+
+ blacklistedSignatureMethods = Set.copyOf(identifiers);
}
/**
@@ -217,8 +215,8 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
*
* @return the set of blacklisted signature method identifiers
*/
- @Nonnull @NonnullElements public Set<String> getBlacklistedSignatureMethods() {
- return Collections.unmodifiableSet(blacklistedSignatureMethods);
+ @Nonnull @NonnullElements @Unmodifiable public Set<String> getBlacklistedSignatureMethods() {
+ return blacklistedSignatureMethods;
}
/**
@@ -285,8 +283,8 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
}
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ @Override
+ protected void doDestroy() {
verificationCertificate = null;
verificationKey = null;
validator = null;
@@ -296,8 +294,8 @@ public class XMLSignatureValidationStage extends AbstractIteratingStage<Element>
super.doDestroy();
}
- /** {@inheritDoc} */
- @Override protected void doInitialize() throws ComponentInitializationException {
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
if (verificationKey == null) {
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java
index 8c6f8f1..85fd833 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStage.java
@@ -18,26 +18,21 @@
package net.shibboleth.metadata.dom.saml;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
-import com.google.common.collect.ImmutableSet;
-
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
import net.shibboleth.metadata.pipeline.StageProcessingException;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -81,11 +76,12 @@ public class ContactPersonFilterStage extends AbstractIteratingStage<Element> {
private final Logger log = LoggerFactory.getLogger(ContactPersonFilterStage.class);
/** Allowed contact person types. */
- private Set<String> allowedTypes = ImmutableSet.copyOf(new String[] {TECHNICAL, SUPPORT, ADMINISTRATIVE, BILLING,
- OTHER,});
+ @Nonnull @NonnullElements @Unmodifiable
+ private final Set<String> allowedTypes = Set.of(TECHNICAL, SUPPORT, ADMINISTRATIVE, BILLING, OTHER);
/** Person types which are white/black listed depending on the value of {@link #whitelistingTypes}. */
- private Set<String> designatedTypes = ImmutableSet.copyOf(allowedTypes);
+ @Nonnull @NonnullElements @Unmodifiable
+ private Set<String> designatedTypes = Set.copyOf(allowedTypes);
/** Whether {@link #designatedTypes} should be considered a whitelist. Default value: true */
private boolean whitelistingTypes = true;
@@ -95,41 +91,32 @@ public class ContactPersonFilterStage extends AbstractIteratingStage<Element> {
*
* @return list of designated person types
*/
- @Nonnull @NonnullElements @Unmodifiable public Collection<String> getDesignateTypes() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public Collection<String> getDesignateTypes() {
return designatedTypes;
}
/**
- * Sets the list of designated entity roles. The list may contain either role element names or schema types.
+ * Sets the designated entity roles. The collection may contain either role element names or schema types.
*
- * @param types list of designated entity roles
+ * @param types collection of designated entity roles
*/
- public synchronized void setDesignatedTypes(@Nullable @NullableElements final Collection<String> types) {
+ public synchronized void setDesignatedTypes(
+ @Nonnull @NonnullElements @Unmodifiable final Collection<String> types) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (types == null || types.isEmpty()) {
- designatedTypes = Collections.emptySet();
- return;
- }
-
- final HashSet<String> checkedTypes = new HashSet<>();
- String checkedType;
+ final Set<String> checkedTypes = new HashSet<>();
for (final String type : types) {
- checkedType = StringSupport.trimOrNull(type);
- if (checkedType == null) {
- continue;
- }
-
- if (allowedTypes.contains(checkedType)) {
- checkedTypes.add(checkedType);
+ if (allowedTypes.contains(type)) {
+ checkedTypes.add(type);
} else {
log.debug("Stage {}: {} is not an allowed contact person type and so has been ignored", getId(),
- checkedType);
+ type);
}
}
- designatedTypes = Collections.unmodifiableSet(checkedTypes);
+ designatedTypes = Set.copyOf(checkedTypes);
}
/**
@@ -234,7 +221,7 @@ public class ContactPersonFilterStage extends AbstractIteratingStage<Element> {
}
if (!isWhitelistingTypes() && !designatedTypes.contains(type)) {
- // if we're blacklist types and the person's type does not appear in the designated type list, keep them
+ // if we're blacklisting types and the person's type does not appear in the designated type list, keep them
return true;
}
@@ -242,9 +229,9 @@ public class ContactPersonFilterStage extends AbstractIteratingStage<Element> {
return false;
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ @Override
+ protected void doDestroy() {
designatedTypes = null;
super.doDestroy();
}
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java
index 729d7f9..e587a5f 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityFilterStage.java
@@ -18,30 +18,24 @@
package net.shibboleth.metadata.dom.saml;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.AbstractFilteringStage;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Element;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
/** A pipeline stage that will remove SAML EntityDescriptior elements which do meet specified filtering criteria. */
@ThreadSafe
public class EntityFilterStage extends AbstractFilteringStage<Element> {
@@ -50,7 +44,8 @@ public class EntityFilterStage extends AbstractFilteringStage<Element> {
private final Logger log = LoggerFactory.getLogger(EntityFilterStage.class);
/** Entities which are white/black listed depending on the value of {@link #whitelistingEntities}. */
- private Collection<String> designatedEntities = Collections.emptyList();
+ @Nonnull @NonnullElements @Unmodifiable
+ private Set<String> designatedEntities = Set.of();
/** Whether {@link #designatedEntities} should be considered a whitelist or a blacklist. Default value: false */
private boolean whitelistingEntities;
@@ -72,15 +67,12 @@ public class EntityFilterStage extends AbstractFilteringStage<Element> {
*
* @param ids list of designated entity IDs
*/
- public synchronized void setDesignatedEntities(@Nullable @NullableElements final Collection<String> ids) {
+ public synchronized void setDesignatedEntities(
+ @Nonnull @NonnullElements @Unmodifiable final Collection<String> ids) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (ids == null || ids.isEmpty()) {
- designatedEntities = Collections.emptyList();
- } else {
- designatedEntities = ImmutableList.copyOf(Iterables.filter(ids, Predicates.notNull()));
- }
+ designatedEntities = Set.copyOf(ids);
}
/**
@@ -125,15 +117,15 @@ public class EntityFilterStage extends AbstractFilteringStage<Element> {
removingEntitylessEntitiesDescriptor = remove;
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ @Override
+ protected void doDestroy() {
designatedEntities = null;
super.doDestroy();
}
- /** {@inheritDoc} */
- @Override protected boolean doExecute(@Nonnull final Item<Element> item) {
+ @Override
+ protected boolean doExecute(@Nonnull final Item<Element> item) {
final Element descriptor = item.unwrap();
if (SAMLMetadataSupport.isEntitiesDescriptor(descriptor)) {
if (processEntitiesDescriptor(descriptor)) {
@@ -217,4 +209,4 @@ public class EntityFilterStage extends AbstractFilteringStage<Element> {
// entity has been filtered and made it through, don't kick it out
return false;
}
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java
index ecd7e97..da9204c 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/EntityRoleFilterStage.java
@@ -18,36 +18,28 @@
package net.shibboleth.metadata.dom.saml;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Set;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
import javax.xml.namespace.QName;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.dom.Element;
+
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.AbstractFilteringStage;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.xml.DOMTypeSupport;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
import net.shibboleth.utilities.java.support.xml.QNameSupport;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.w3c.dom.Element;
-
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.ImmutableSet;
-import com.google.common.collect.Iterables;
-
/**
* A pipeline stage that will filter SAML role descriptors from EntityDescriptors.
*
@@ -85,11 +77,13 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
* {@link #SP_SSO_DESCRIPTOR_NAME}, {@link #AUTHN_AUTHORITY_DESCRIPTOR_NAME},
* {@link #ATTRIBUTE_AUTHORITY_DESCRIPTOR_NAME}, {@link #PDP_DESCRIPTOR_NAME}.
*/
- private final Set<QName> namedRoles = ImmutableSet.of(IDP_SSO_DESCRIPTOR_NAME, SP_SSO_DESCRIPTOR_NAME,
+ @Nonnull @NonnullElements @Unmodifiable
+ private final Set<QName> namedRoles = Set.of(IDP_SSO_DESCRIPTOR_NAME, SP_SSO_DESCRIPTOR_NAME,
AUTHN_AUTHORITY_DESCRIPTOR_NAME, ATTRIBUTE_AUTHORITY_DESCRIPTOR_NAME, PDP_DESCRIPTOR_NAME);
/** Role element or type names which are white/black listed depending on the value of {@link #whitelistingRoles}. */
- private Collection<QName> designatedRoles = Collections.emptyList();
+ @Nonnull @NonnullElements @Unmodifiable
+ private Set<QName> designatedRoles = Set.of();
/** Whether {@link #designatedRoles} should be considered a whitelist or a blacklist. Default value: false */
private boolean whitelistingRoles;
@@ -108,7 +102,8 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
*
* @return list of designated entity roles, never null
*/
- @Nonnull @NonnullElements @Unmodifiable public Collection<QName> getDesignatedRoles() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public Collection<QName> getDesignatedRoles() {
return designatedRoles;
}
@@ -117,15 +112,11 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
*
* @param roles list of designated entity roles
*/
- public synchronized void setDesignatedRoles(@Nullable @NullableElements final Collection<QName> roles) {
+ public synchronized void setDesignatedRoles(@Nonnull @NonnullElements @Unmodifiable final Collection<QName> roles) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (roles == null || roles.isEmpty()) {
- designatedRoles = Collections.emptyList();
- } else {
- designatedRoles = ImmutableList.copyOf(Iterables.filter(roles, Predicates.notNull()));
- }
+ designatedRoles = Set.copyOf(roles);
}
/**
@@ -191,15 +182,15 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
removingEntitylessEntitiesDescriptor = remove;
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ @Override
+ protected void doDestroy() {
designatedRoles = null;
super.doDestroy();
}
- /** {@inheritDoc} */
- @Override protected boolean doExecute(@Nonnull final Item<Element> item) {
+ @Override
+ protected boolean doExecute(@Nonnull final Item<Element> item) {
final Element descriptor = item.unwrap();
if (SAMLMetadataSupport.isEntitiesDescriptor(descriptor)) {
if (processEntitiesDescriptor(descriptor)) {
@@ -329,4 +320,4 @@ public class EntityRoleFilterStage extends AbstractFilteringStage<Element> {
return childElements;
}
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java
index 3b4c455..11cca7c 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdattr/EntityAttributeFilteringStage.java
@@ -17,7 +17,6 @@
package net.shibboleth.metadata.dom.saml.mdattr;
-import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
@@ -36,6 +35,8 @@ import net.shibboleth.metadata.dom.saml.SAMLMetadataSupport;
import net.shibboleth.metadata.dom.saml.SAMLSupport;
import net.shibboleth.metadata.dom.saml.mdrpi.RegistrationAuthority;
import net.shibboleth.metadata.pipeline.AbstractIteratingStage;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
import net.shibboleth.utilities.java.support.xml.ElementSupport;
@@ -197,7 +198,8 @@ public class EntityAttributeFilteringStage extends AbstractIteratingStage<Elemen
* This amounts to an implicit ORing of the individual rules, with early
* termination.
*/
- private List<Predicate<EntityAttributeContext>> rules = Collections.emptyList();
+ @Nonnull @NonnullElements @Unmodifiable
+ private List<Predicate<EntityAttributeContext>> rules = List.of();
/** Mode of operation: whitelisting or blacklisting. Default: whitelisting. */
private boolean whitelisting = true;
@@ -210,11 +212,12 @@ public class EntityAttributeFilteringStage extends AbstractIteratingStage<Elemen
*
* @param newRules new {@link List} of rules
*/
- public void setRules(@Nonnull final List<Predicate<EntityAttributeContext>> newRules) {
+ public void setRules(
+ @Nonnull @NonnullElements @Unmodifiable final List<Predicate<EntityAttributeContext>> newRules) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- rules = Constraint.isNotNull(newRules, "rules property may not be null");
+ rules = List.copyOf(Constraint.isNotNull(newRules, "rules property may not be null"));
}
/**
@@ -222,9 +225,9 @@ public class EntityAttributeFilteringStage extends AbstractIteratingStage<Elemen
*
* @return the {@link List} of rules
*/
- @Nonnull
+ @Nonnull @NonnullElements @Unmodifiable
public List<Predicate<EntityAttributeContext>> getRules() {
- return Collections.unmodifiableList(rules);
+ return rules;
}
/**
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java
index 0f5f14d..e2fb727 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/EntityRegistrationAuthorityFilterStage.java
@@ -18,27 +18,21 @@
package net.shibboleth.metadata.dom.saml.mdrpi;
import java.util.Collection;
-import java.util.Collections;
import java.util.Iterator;
import java.util.List;
+import java.util.Set;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.w3c.dom.Element;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.dom.saml.SAMLMetadataSupport;
import net.shibboleth.metadata.pipeline.AbstractFilteringStage;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.xml.AttributeSupport;
@@ -55,7 +49,8 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
private boolean requiringRegistrationInformation;
/** Registrars which are white/black listed depending on the value of {@link #whitelistingAuthorities}. */
- private Collection<String> designatedAuthorities = Collections.emptyList();
+ @Nonnull @NonnullElements @Unmodifiable
+ private Set<String> designatedAuthorities = Set.of();
/** Whether {@link #designatedAuthorities} should be considered a whitelist or a blacklist. Default value: false */
private boolean whitelistingAuthorities;
@@ -89,7 +84,8 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
*
* @return list of designated registration authority, never null
*/
- @Nonnull @NonnullElements @Unmodifiable public Collection<String> getDesignatedRegistrationAuthorities() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public Collection<String> getDesignatedRegistrationAuthorities() {
return designatedAuthorities;
}
@@ -99,15 +95,11 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
* @param authorities list of designated registration authority
*/
public synchronized void setDesignatedRegistrationAuthorities(
- @Nullable @NullableElements final Collection<String> authorities) {
+ @Nonnull @NonnullElements @Unmodifiable final Collection<String> authorities) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (authorities == null || authorities.isEmpty()) {
- designatedAuthorities = Collections.emptyList();
- } else {
- designatedAuthorities = ImmutableList.copyOf(Iterables.filter(authorities, Predicates.notNull()));
- }
+ designatedAuthorities = Set.copyOf(authorities);
}
/**
@@ -153,15 +145,15 @@ public class EntityRegistrationAuthorityFilterStage extends AbstractFilteringSta
removingEntitylessEntitiesDescriptor = remove;
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ @Override
+ protected void doDestroy() {
designatedAuthorities = null;
super.doDestroy();
}
- /** {@inheritDoc} */
- @Override protected boolean doExecute(@Nonnull final Item<Element> item) {
+ @Override
+ protected boolean doExecute(@Nonnull final Item<Element> item) {
final Element descriptor;
descriptor = item.unwrap();
if (SAMLMetadataSupport.isEntitiesDescriptor(descriptor)) {
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/RegistrationAuthorityItemIdentificationStrategy.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/RegistrationAuthorityItemIdentificationStrategy.java
index 3ecfdfa..bb25a08 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/RegistrationAuthorityItemIdentificationStrategy.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/dom/saml/mdrpi/RegistrationAuthorityItemIdentificationStrategy.java
@@ -18,7 +18,6 @@
package net.shibboleth.metadata.dom.saml.mdrpi;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.Map;
import java.util.Set;
@@ -27,11 +26,10 @@ import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
-import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.ImmutableSet;
-
import net.shibboleth.metadata.FirstItemIdItemIdentificationStrategy;
import net.shibboleth.metadata.Item;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
/**
* Item identification strategy for interfederation use cases.
@@ -49,19 +47,22 @@ public class RegistrationAuthorityItemIdentificationStrategy extends FirstItemId
/**
* Set of registration authorities to be ignored.
*/
- @Nonnull private Set<String> ignoredRegistrationAuthorities = Collections.emptySet();
+ @Nonnull @NonnullElements @Unmodifiable
+ private Set<String> ignoredRegistrationAuthorities = Set.of();
/**
* Replacement display names for registration authorities.
*/
- @Nonnull private Map<String, String> registrationAuthorityDisplayNames = Collections.emptyMap();
+ @Nonnull @NonnullElements @Unmodifiable
+ private Map<String, String> registrationAuthorityDisplayNames = Map.of();
/**
* Returns the set of registration authorities we are ignoring.
*
* @return {@link Set} of registration authority names.
*/
- @Nonnull public Collection<String> getIgnoredRegistrationAuthorities() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public Collection<String> getIgnoredRegistrationAuthorities() {
return ignoredRegistrationAuthorities;
}
@@ -70,12 +71,9 @@ public class RegistrationAuthorityItemIdentificationStrategy extends FirstItemId
*
* @param registrars {@link Set} of registration authority names to ignore.
*/
- public void setIgnoredRegistrationAuthorities(@Nullable final Collection<String> registrars) {
- if (registrars == null || registrars.isEmpty()) {
- ignoredRegistrationAuthorities = Collections.emptySet();
- } else {
- ignoredRegistrationAuthorities = ImmutableSet.copyOf(registrars);
- }
+ public void setIgnoredRegistrationAuthorities(
+ @Nonnull @NonnullElements @Unmodifiable final Collection<String> registrars) {
+ ignoredRegistrationAuthorities = Set.copyOf(registrars);
}
/**
@@ -83,6 +81,7 @@ public class RegistrationAuthorityItemIdentificationStrategy extends FirstItemId
*
* @return {@link Map} of display names for authorities.
*/
+ @Nonnull @NonnullElements @Unmodifiable
public Map<String, String> getRegistrationAuthorityDisplayNames() {
return registrationAuthorityDisplayNames;
}
@@ -92,12 +91,9 @@ public class RegistrationAuthorityItemIdentificationStrategy extends FirstItemId
*
* @param names {@link Map} of display names for registration authorities.
*/
- public void setRegistrationAuthorityDisplayNames(@Nullable final Map<String, String> names) {
- if (names == null || names.isEmpty()) {
- registrationAuthorityDisplayNames = Collections.emptyMap();
- } else {
- registrationAuthorityDisplayNames = ImmutableMap.copyOf(names);
- }
+ public void setRegistrationAuthorityDisplayNames(
+ @Nonnull @NonnullElements @Unmodifiable final Map<String, String> names) {
+ registrationAuthorityDisplayNames = Map.copyOf(names);
}
/**
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java
index 4e4a05e..8ed6115 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/AbstractItemMetadataSelectionStage.java
@@ -19,13 +19,12 @@ package net.shibboleth.metadata.pipeline;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.Set;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.FirstItemIdItemIdentificationStrategy;
@@ -33,15 +32,10 @@ import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.ItemIdentificationStrategy;
import net.shibboleth.metadata.ItemMetadata;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
/**
* An abstract {@link Stage} that selects {@link Item}s for further processing if they have a specific
* type of {@link ItemMetadata} attached to them.
@@ -51,17 +45,20 @@ import com.google.common.collect.Iterables;
@ThreadSafe
public abstract class AbstractItemMetadataSelectionStage<T> extends AbstractStage<T> {
- /** {@link ItemMetadata} classes that, if the an item contains, will cause the {@link Item} to be selected. */
- private Collection<Class<? extends ItemMetadata>> selectionRequirements = Collections.emptyList();
+ /**
+ * {@link ItemMetadata} classes that, if an item contains them, will cause the {@link Item} to be selected.
+ */
+ @Nonnull @NonnullElements @Unmodifiable
+ private Set<Class<? extends ItemMetadata>> selectionRequirements = Set.of();
/** Strategy used to generate item identifiers for logging purposes. */
private ItemIdentificationStrategy identificationStrategy = new FirstItemIdItemIdentificationStrategy();
/**
- * Gets the {@link ItemMetadata} classes that, if the an item contains, will cause the {@link Item} to be
+ * Gets the {@link ItemMetadata} classes that, if an item contains them, will cause the {@link Item} to be
* selected.
*
- * @return {@link ItemMetadata} classes that, if the an item contains, will cause the {@link Item} to be
+ * @return {@link ItemMetadata} classes that, if an item contains them, will cause the {@link Item} to be
* selected, never null nor containing null elements
*/
@Nonnull @NonnullElements @Unmodifiable
@@ -70,22 +67,18 @@ public abstract class AbstractItemMetadataSelectionStage<T> extends AbstractStag
}
/**
- * Sets the {@link ItemMetadata} classes that, if the an item contains, will cause the {@link Item} to be
+ * Sets the {@link ItemMetadata} classes that, if an item contains them, will cause the {@link Item} to be
* selected.
*
- * @param requirements {@link ItemMetadata} classes that, if the an item contains, will cause the
- * {@link Item} to be selected, may be null or contain null elements
+ * @param requirements {@link ItemMetadata} classes that, if an item contains them, will cause the
+ * {@link Item} to be selected
*/
public synchronized void setSelectionRequirements(
- @Nullable @NullableElements final Collection<Class<? extends ItemMetadata>> requirements) {
+ @Nonnull @NonnullElements @Unmodifiable final Collection<Class<? extends ItemMetadata>> requirements) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (requirements == null) {
- selectionRequirements = Collections.emptyList();
- } else {
- selectionRequirements = ImmutableList.copyOf(Iterables.filter(requirements, Predicates.notNull()));
- }
+ selectionRequirements = Set.copyOf(requirements);
}
/**
@@ -109,8 +102,8 @@ public abstract class AbstractItemMetadataSelectionStage<T> extends AbstractStag
identificationStrategy = Constraint.isNotNull(strategy, "Item identification strategy can not be null");
}
- /** {@inheritDoc} */
- @Override protected void doExecute(final Collection<Item<T>> itemCollection) throws StageProcessingException {
+ @Override
+ protected void doExecute(final Collection<Item<T>> itemCollection) throws StageProcessingException {
// we make a defensive copy here in case logic in the delegate #doExecute makes changes
// to the itemCollection and thus would cause issues if we were iterating over it directly
final ArrayList<Item<T>> collectionCopy = new ArrayList<>(itemCollection);
@@ -131,8 +124,8 @@ public abstract class AbstractItemMetadataSelectionStage<T> extends AbstractStag
}
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ @Override
+ protected void doDestroy() {
selectionRequirements = null;
identificationStrategy = null;
@@ -156,4 +149,4 @@ public abstract class AbstractItemMetadataSelectionStage<T> extends AbstractStag
@Nonnull @NonnullElements
final Map<Class<? extends ItemMetadata>, List<? extends ItemMetadata>> matchingMetadata)
throws StageProcessingException;
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/CompositeStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/CompositeStage.java
index 55f4500..3546715 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/CompositeStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/CompositeStage.java
@@ -17,19 +17,15 @@
package net.shibboleth.metadata.pipeline;
-import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
-import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
/**
@@ -42,40 +38,33 @@ import net.shibboleth.utilities.java.support.component.ComponentSupport;
public class CompositeStage<T> extends AbstractStage<T> {
/** Stages which compose this stage. */
- private List<Stage<T>> composedStages = Collections.emptyList();
+ @Nonnull @NonnullElements @Unmodifiable
+ private List<Stage<T>> composedStages = List.of();
/**
- * Gets an unmodifiable list the stages that compose this stage.
+ * Gets an unmodifiable list of the stages that compose this stage.
*
* @return list the stages that compose this stage, never null nor containing null elements
*/
- @Nonnull @NonnullElements public List<Stage<T>> getComposedStages() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public List<Stage<T>> getComposedStages() {
return composedStages;
}
/**
- * Sets the list the stages that compose this stage.
+ * Sets the list of stages that compose this stage.
*
- * @param stages list the stages that compose this stage, may be null or contain null elements
+ * @param stages list of the stages that compose this stage
*/
- public synchronized void setComposedStages(@Nullable @NullableElements final List<Stage<T>> stages) {
+ public synchronized void setComposedStages(
+ @Nonnull @NonnullElements @Unmodifiable final List<Stage<T>> stages) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- final ArrayList<Stage<T>> newStages = new ArrayList<>();
- if (stages != null) {
- for (final Stage<T> stage : stages) {
- if (stage != null) {
- newStages.add(stage);
- }
- }
- }
-
- composedStages = Collections.unmodifiableList(newStages);
+ composedStages = List.copyOf(stages);
}
- /** {@inheritDoc} */
@Override
protected void doExecute(@Nonnull @NonnullElements final Collection<Item<T>> itemCollection)
throws StageProcessingException {
@@ -84,19 +73,10 @@ public class CompositeStage<T> extends AbstractStage<T> {
}
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ @Override
+ protected void doDestroy() {
composedStages = null;
super.doDestroy();
}
-
- /** {@inheritDoc} */
- @Override protected void doInitialize() throws ComponentInitializationException {
- super.doInitialize();
-
- if (composedStages == null || composedStages.isEmpty()) {
- composedStages = Collections.emptyList();
- }
- }
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemIdTransformStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemIdTransformStage.java
index c108653..2a8dabc 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemIdTransformStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemIdTransformStage.java
@@ -20,7 +20,6 @@ package net.shibboleth.metadata.pipeline;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-import java.util.stream.Collectors;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
@@ -29,7 +28,8 @@ import com.google.common.base.Function;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.ItemId;
-import net.shibboleth.utilities.java.support.collection.LazyList;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
/**
@@ -43,13 +43,15 @@ import net.shibboleth.utilities.java.support.component.ComponentSupport;
public class ItemIdTransformStage<T> extends AbstractIteratingStage<T> {
/** Transformers used on IDs. */
- private Collection<Function<String, String>> idTransformers = new LazyList<>();
+ @Nonnull @NonnullElements @Unmodifiable
+ private List<Function<String, String>> idTransformers = List.of();
/**
* Gets the transforms used to produce the transformed entity IDs.
*
* @return transforms used to produce the transformed entity IDs, never null
*/
+ @Nonnull @NonnullElements @Unmodifiable
public Collection<Function<String, String>> getIdTransformers() {
return idTransformers;
}
@@ -59,11 +61,12 @@ public class ItemIdTransformStage<T> extends AbstractIteratingStage<T> {
*
* @param transformers transforms used to produce the transformed entity IDs
*/
- public synchronized void setIdTransformers(final Collection<Function<String, String>> transformers) {
+ public synchronized void setIdTransformers(
+ @Nonnull @NonnullElements @Unmodifiable final Collection<Function<String, String>> transformers) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- idTransformers.addAll(transformers.stream().filter(e -> e!=null).collect(Collectors.toList()));
+ idTransformers = List.copyOf(transformers);
}
@Override
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemMetadataAddingStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemMetadataAddingStage.java
index cb140c0..e7dd741 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemMetadataAddingStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/ItemMetadataAddingStage.java
@@ -18,14 +18,15 @@
package net.shibboleth.metadata.pipeline;
import java.util.Collection;
-import java.util.stream.Collectors;
+import java.util.List;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.ItemMetadata;
-import net.shibboleth.utilities.java.support.collection.LazyList;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
@@ -38,14 +39,15 @@ import net.shibboleth.utilities.java.support.logic.Constraint;
public class ItemMetadataAddingStage<T> extends AbstractIteratingStage<T> {
/** {@link ItemMetadata} objects to add to each {@link Item}'s item metadata. */
- private Collection<ItemMetadata> additionalItemMetadata = new LazyList<>();
+ @Nonnull @NonnullElements @Unmodifiable
+ private List<ItemMetadata> additionalItemMetadata = List.of();
/**
* Gets the {@link ItemMetadata} being added to each {@link Item}'s item metadata.
*
* @return the {@link ItemMetadata} being added to each {@link Item}'s item metadata
*/
- @Nonnull
+ @Nonnull @NonnullElements @Unmodifiable
public Collection<ItemMetadata> getAdditionalItemMetadata() {
return additionalItemMetadata;
}
@@ -55,12 +57,13 @@ public class ItemMetadataAddingStage<T> extends AbstractIteratingStage<T> {
*
* @param metadata the {@link ItemMetadata} to be added to each {@link Item}'s item metadata
*/
- public void setAdditionalItemMetadata(@Nonnull final Collection<ItemMetadata> metadata) {
+ public void setAdditionalItemMetadata(
+ @Nonnull @NonnullElements @Unmodifiable final Collection<ItemMetadata> metadata) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
Constraint.isNotNull(metadata, "additional metadata collection must not be null");
- additionalItemMetadata = metadata.stream().filter(e -> e!=null).collect(Collectors.toList());
+ additionalItemMetadata = List.copyOf(metadata);
}
@Override
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/Pipeline.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/Pipeline.java
index 5a77867..304d91c 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/Pipeline.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/Pipeline.java
@@ -25,6 +25,7 @@ import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.DestructableComponent;
import net.shibboleth.utilities.java.support.component.IdentifiedComponent;
import net.shibboleth.utilities.java.support.component.InitializableComponent;
@@ -51,7 +52,8 @@ public interface Pipeline<T> extends DestructableComponent, IdentifiedComponent,
*
* @return unmodifiable list of stages within the pipeline
*/
- @Nonnull @NonnullElements public List<Stage<T>> getStages();
+ @Nonnull @NonnullElements @Unmodifiable
+ List<Stage<T>> getStages();
/**
* Executes each registered {@link Stage} in turn.
@@ -60,6 +62,6 @@ public interface Pipeline<T> extends DestructableComponent, IdentifiedComponent,
*
* @throws PipelineProcessingException thrown if there is a problem processing the pipeline
*/
- public void execute(@Nonnull @NonnullElements final Collection<Item<T>> itemCollection)
+ void execute(@Nonnull @NonnullElements final Collection<Item<T>> itemCollection)
throws PipelineProcessingException;
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineDemultiplexerStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineDemultiplexerStage.java
index 821104e..112cdba 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineDemultiplexerStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineDemultiplexerStage.java
@@ -19,7 +19,6 @@ package net.shibboleth.metadata.pipeline;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@@ -28,6 +27,9 @@ import java.util.concurrent.Future;
import javax.annotation.Nonnull;
import javax.annotation.concurrent.ThreadSafe;
+import com.google.common.base.Predicate;
+import com.google.common.base.Supplier;
+
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.SimpleItemCollectionFactory;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
@@ -37,10 +39,6 @@ import net.shibboleth.utilities.java.support.component.ComponentInitializationEx
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
-import com.google.common.base.Predicate;
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableList.Builder;
-
/**
* A stage which, given an item collection and a list of {@link Pipeline} and {@link Predicate} pairs, sends the
* collection of item copies selected by the predicate to the associated pipeline. This stage is similar to
@@ -78,7 +76,8 @@ public class PipelineDemultiplexerStage<T> extends AbstractStage<T> {
private Supplier<Collection<Item<T>>> collectionFactory = new SimpleItemCollectionFactory<>();
/** The pipelines through which items are sent and the selection strategy used for that pipeline. */
- private List<Pair<Pipeline<T>, Predicate<Item<T>>>> pipelineAndStrategies = Collections.emptyList();
+ @Nonnull @NonnullElements @Unmodifiable
+ private List<Pair<Pipeline<T>, Predicate<Item<T>>>> pipelineAndStrategies = List.of();
/**
* Gets the executor service used to run the selected and non-selected item pipelines.
@@ -159,28 +158,20 @@ public class PipelineDemultiplexerStage<T> extends AbstractStage<T> {
* @param passes pipeline and item selection strategies used to demultiplex item collections within this stage
*/
public synchronized void setPipelineAndSelectionStrategies(
- @Nonnull @NonnullElements final List<Pair<Pipeline<T>, Predicate<Item<T>>>> passes) {
+ @Nonnull @NonnullElements @Unmodifiable final List<Pair<Pipeline<T>, Predicate<Item<T>>>> passes) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (passes == null || passes.isEmpty()) {
- pipelineAndStrategies = Collections.emptyList();
- return;
- }
-
- final Builder<Pair<Pipeline<T>, Predicate<Item<T>>>> checkedPasses = new Builder<>();
for (final Pair<Pipeline<T>, Predicate<Item<T>>> pass : passes) {
Constraint.isNotNull(pass.getFirst(), "Pipeline can not be null");
Constraint.isNotNull(pass.getSecond(), "Predicate can not be null");
-
- checkedPasses.add(new Pair<>(pass));
}
- pipelineAndStrategies = checkedPasses.build();
+ pipelineAndStrategies = List.copyOf(passes);
}
- /** {@inheritDoc} */
- @Override protected void doExecute(@Nonnull @NonnullElements final Collection<Item<T>> itemCollection)
+ @Override
+ protected void doExecute(@Nonnull @NonnullElements final Collection<Item<T>> itemCollection)
throws StageProcessingException {
Collection<Item<T>> selectedItems;
final ArrayList<Future<Collection<Item<T>>>> pipelineFutures = new ArrayList<>();
@@ -208,8 +199,8 @@ public class PipelineDemultiplexerStage<T> extends AbstractStage<T> {
}
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ @Override
+ protected void doDestroy() {
executorService = null;
collectionFactory = null;
pipelineAndStrategies = null;
@@ -217,21 +208,20 @@ public class PipelineDemultiplexerStage<T> extends AbstractStage<T> {
super.doDestroy();
}
- /** {@inheritDoc} */
- @Override protected void doInitialize() throws ComponentInitializationException {
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
if (pipelineAndStrategies.isEmpty()) {
throw new ComponentInitializationException(
- "Pipeline and selection strategy collection can not be null or empty");
+ "Pipeline and selection strategy collection can not be empty");
}
- Pipeline<T> pipeline;
for (final Pair<Pipeline<T>, Predicate<Item<T>>> pipelineAndStrategy : pipelineAndStrategies) {
- pipeline = pipelineAndStrategy.getFirst();
+ final var pipeline = pipelineAndStrategy.getFirst();
if (!pipeline.isInitialized()) {
pipeline.initialize();
}
}
}
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineMergeStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineMergeStage.java
index 55b0e20..41caf26 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineMergeStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/PipelineMergeStage.java
@@ -19,32 +19,26 @@ package net.shibboleth.metadata.pipeline;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Collections;
import java.util.List;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
+import com.google.common.base.Supplier;
+
import net.shibboleth.metadata.CollectionMergeStrategy;
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.SimpleCollectionMergeStrategy;
import net.shibboleth.metadata.SimpleItemCollectionFactory;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
import net.shibboleth.utilities.java.support.logic.Constraint;
-import com.google.common.base.Predicates;
-import com.google.common.base.Supplier;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
/**
* This {@link Stage} allows the merging of multiple pipeline outputs into a single {@link Collection} that can then be
* used as the input source for another pipeline.
@@ -72,7 +66,8 @@ public class PipelineMergeStage<T> extends AbstractStage<T> {
private CollectionMergeStrategy mergeStrategy = new SimpleCollectionMergeStrategy();
/** Pipelines whose results become the output of this source. */
- private List<Pipeline<T>> mergedPipelines = Collections.emptyList();
+ @Nonnull @NonnullElements @Unmodifiable
+ private List<Pipeline<T>> mergedPipelines = List.of();
/**
* Gets the executor service used to run the selected and non-selected item pipelines.
@@ -100,7 +95,8 @@ public class PipelineMergeStage<T> extends AbstractStage<T> {
*
* @return unmodifiable set of pipelines used by this stage
*/
- @Nonnull @NonnullElements @Unmodifiable public List<Pipeline<T>> getMergedPipelines() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public List<Pipeline<T>> getMergedPipelines() {
return mergedPipelines;
}
@@ -110,16 +106,11 @@ public class PipelineMergeStage<T> extends AbstractStage<T> {
* @param pipelines pipelines joined by this stage
*/
public synchronized void setMergedPipelines(
- @Nullable @NullableElements final List<? extends Pipeline<T>> pipelines) {
+ @Nonnull @NonnullElements @Unmodifiable final List<? extends Pipeline<T>> pipelines) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (pipelines == null || pipelines.isEmpty()) {
- mergedPipelines = Collections.emptyList();
- } else {
- mergedPipelines = ImmutableList.copyOf(Iterables.filter(pipelines, Predicates.notNull()));
- }
-
+ mergedPipelines = List.copyOf(pipelines);
}
/**
@@ -165,8 +156,8 @@ public class PipelineMergeStage<T> extends AbstractStage<T> {
mergeStrategy = strategy;
}
- /** {@inheritDoc} */
- @Override protected void doExecute(@Nonnull @NonnullElements final Collection<Item<T>> itemCollection)
+ @Override
+ protected void doExecute(@Nonnull @NonnullElements final Collection<Item<T>> itemCollection)
throws StageProcessingException {
final ArrayList<Future<Collection<Item<T>>>> pipelineResultFutures = new ArrayList<>();
@@ -183,8 +174,8 @@ public class PipelineMergeStage<T> extends AbstractStage<T> {
mergeStrategy.mergeCollection(itemCollection, pipelineResults);
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ @Override
+ protected void doDestroy() {
executorService = null;
collectionFactory = null;
mergeStrategy = null;
@@ -193,8 +184,8 @@ public class PipelineMergeStage<T> extends AbstractStage<T> {
super.doDestroy();
}
- /** {@inheritDoc} */
- @Override protected void doInitialize() throws ComponentInitializationException {
+ @Override
+ protected void doInitialize() throws ComponentInitializationException {
super.doInitialize();
for (final Pipeline<T> pipeline : mergedPipelines) {
@@ -203,4 +194,4 @@ public class PipelineMergeStage<T> extends AbstractStage<T> {
}
}
}
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java
index 8d57388..5b3def4 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/SimplePipeline.java
@@ -32,10 +32,6 @@ import net.shibboleth.utilities.java.support.component.AbstractIdentifiableIniti
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
/**
* A very simple implementation of {@link Pipeline}.
*
@@ -48,8 +44,9 @@ public class SimplePipeline<T> extends AbstractIdentifiableInitializableComponen
/** Stages for this pipeline. */
private List<Stage<T>> pipelineStages = Collections.emptyList();
- /** {@inheritDoc} */
- @Override @Nonnull @NonnullElements @Unmodifiable public List<Stage<T>> getStages() {
+ @Override
+ @Nonnull @NonnullElements @Unmodifiable
+ public List<Stage<T>> getStages() {
return pipelineStages;
}
@@ -58,15 +55,12 @@ public class SimplePipeline<T> extends AbstractIdentifiableInitializableComponen
*
* @param stages stages that make up this pipeline
*/
- public synchronized void setStages(final List<Stage<T>> stages) {
+ public synchronized void setStages(
+ @Nonnull @NonnullElements @Unmodifiable final List<Stage<T>> stages) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (stages == null || stages.isEmpty()) {
- pipelineStages = Collections.emptyList();
- } else {
- pipelineStages = ImmutableList.copyOf(Iterables.filter(stages, Predicates.notNull()));
- }
+ pipelineStages = List.copyOf(stages);
}
/** {@inheritDoc} */
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/StaticItemSourceStage.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/StaticItemSourceStage.java
index 8f5dfbd..de2e6ab 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/StaticItemSourceStage.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/pipeline/StaticItemSourceStage.java
@@ -18,22 +18,16 @@
package net.shibboleth.metadata.pipeline;
import java.util.Collection;
-import java.util.Collections;
+import java.util.List;
import javax.annotation.Nonnull;
-import javax.annotation.Nullable;
import javax.annotation.concurrent.ThreadSafe;
import net.shibboleth.metadata.Item;
import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
-import net.shibboleth.utilities.java.support.annotation.constraint.NullableElements;
import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
/**
* A stage which adds a static collection of Items to a {@link Item} collection.
*
@@ -43,14 +37,16 @@ import com.google.common.collect.Iterables;
public class StaticItemSourceStage<T> extends AbstractStage<T> {
/** Collection of static Items added to each Item collection by {@link #execute(Collection)}. */
- private Collection<Item<T>> source = Collections.emptyList();
+ @Nonnull @NonnullElements @Unmodifiable
+ private List<Item<T>> source = List.of();
/**
* Gets the collection of static Items added to the Item collection by this stage.
*
* @return collection of static Items added to the Item collection by this stage
*/
- @Nonnull @NonnullElements @Unmodifiable public Collection<Item<T>> getSourceItems() {
+ @Nonnull @NonnullElements @Unmodifiable
+ public Collection<Item<T>> getSourceItems() {
return source;
}
@@ -59,19 +55,16 @@ public class StaticItemSourceStage<T> extends AbstractStage<T> {
*
* @param items collection of Items added to the Item collection by this stage
*/
- public synchronized void setSourceItems(@Nullable @NullableElements final Collection<Item<T>> items) {
+ public synchronized void setSourceItems(
+ @Nonnull @NonnullElements @Unmodifiable final Collection<Item<T>> items) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- if (items == null || items.isEmpty()) {
- source = Collections.emptyList();
- } else {
- source = ImmutableList.copyOf(Iterables.filter(items, Predicates.notNull()));
- }
+ source = List.copyOf(items);
}
- /** {@inheritDoc} */
- @Override protected void doExecute(@Nonnull @NonnullElements final Collection<Item<T>> itemCollection)
+ @Override
+ protected void doExecute(@Nonnull @NonnullElements final Collection<Item<T>> itemCollection)
throws StageProcessingException {
for (final Item<T> item : getSourceItems()) {
if (item != null) {
@@ -80,10 +73,10 @@ public class StaticItemSourceStage<T> extends AbstractStage<T> {
}
}
- /** {@inheritDoc} */
- @Override protected void doDestroy() {
+ @Override
+ protected void doDestroy() {
source = null;
super.doDestroy();
}
-}
\ No newline at end of file
+}
diff --git a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/ValidatorSequence.java b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/ValidatorSequence.java
index 4ede415..db91ac8 100644
--- a/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/ValidatorSequence.java
+++ b/aggregator-pipeline/src/main/java/net/shibboleth/metadata/validate/ValidatorSequence.java
@@ -17,17 +17,14 @@
package net.shibboleth.metadata.validate;
-import java.util.Collections;
import java.util.List;
import javax.annotation.Nonnull;
-import com.google.common.base.Predicates;
-import com.google.common.collect.ImmutableList;
-import com.google.common.collect.Iterables;
-
import net.shibboleth.metadata.Item;
import net.shibboleth.metadata.pipeline.StageProcessingException;
+import net.shibboleth.utilities.java.support.annotation.constraint.NonnullElements;
+import net.shibboleth.utilities.java.support.annotation.constraint.Unmodifiable;
import net.shibboleth.utilities.java.support.component.ComponentInitializationException;
import net.shibboleth.utilities.java.support.component.ComponentSupport;
@@ -44,19 +41,19 @@ import net.shibboleth.utilities.java.support.component.ComponentSupport;
public class ValidatorSequence<V> extends BaseValidator implements Validator<V> {
/** The list of validators to apply. */
- @Nonnull
- private List<Validator<V>> validators = Collections.emptyList();
+ @Nonnull @NonnullElements @Unmodifiable
+ private List<Validator<V>> validators = List.of();
/**
* Set the list of validators to apply to each item.
*
* @param newValidators the list of validators to set
*/
- public void setValidators(@Nonnull final List<Validator<V>> newValidators) {
+ public void setValidators(@Nonnull @NonnullElements @Unmodifiable final List<Validator<V>> newValidators) {
ComponentSupport.ifDestroyedThrowDestroyedComponentException(this);
ComponentSupport.ifInitializedThrowUnmodifiabledComponentException(this);
- validators = ImmutableList.copyOf(Iterables.filter(newValidators, Predicates.notNull()));
+ validators = List.copyOf(newValidators);
}
/**
@@ -64,9 +61,9 @@ public class ValidatorSequence<V> extends BaseValidator implements Validator<V>
*
* @return list of validators
*/
- @Nonnull
+ @Nonnull @NonnullElements @Unmodifiable
public List<Validator<V>> getValidators() {
- return Collections.unmodifiableList(validators);
+ return validators;
}
@Override
diff --git a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStageTest.java b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStageTest.java
index 2399f56..0fe859f 100644
--- a/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStageTest.java
+++ b/aggregator-pipeline/src/test/java/net/shibboleth/metadata/dom/saml/ContactPersonFilterStageTest.java
@@ -20,6 +20,7 @@ package net.shibboleth.metadata.dom.saml;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Set;
import javax.xml.namespace.QName;
@@ -46,7 +47,7 @@ public class ContactPersonFilterStageTest extends BaseDOMTest {
super(ContactPersonFilterStage.class);
}
- private final QName contactPersonQname = new QName("urn:oasis:names:tc:SAML:2.0:metadata", "ContactPerson");
+ private final QName contactPersonQname = new QName(SAMLMetadataSupport.MD_NS, "ContactPerson");
private Element entitiesDescriptor;
@@ -64,7 +65,7 @@ public class ContactPersonFilterStageTest extends BaseDOMTest {
Assert.assertTrue(stage.getDesignateTypes().contains(ContactPersonFilterStage.SUPPORT));
Assert.assertTrue(stage.getDesignateTypes().contains(ContactPersonFilterStage.TECHNICAL));
- stage.setDesignatedTypes(Sets.newHashSet(ContactPersonFilterStage.ADMINISTRATIVE, null,
+ stage.setDesignatedTypes(Set.of(ContactPersonFilterStage.ADMINISTRATIVE,
ContactPersonFilterStage.TECHNICAL, "", "foo", ContactPersonFilterStage.OTHER));
Assert.assertEquals(stage.getDesignateTypes().size(), 3);
Assert.assertTrue(stage.getDesignateTypes().contains(ContactPersonFilterStage.ADMINISTRATIVE));
@@ -74,12 +75,9 @@ public class ContactPersonFilterStageTest extends BaseDOMTest {
stage.setDesignatedTypes(Collections.<String>emptyList());
Assert.assertEquals(stage.getDesignateTypes().size(), 0);
- stage.setDesignatedTypes(null);
- Assert.assertEquals(stage.getDesignateTypes().size(), 0);
-
stage.initialize();
try {
- stage.setDesignatedTypes(Sets.newHashSet(ContactPersonFilterStage.ADMINISTRATIVE));
+ stage.setDesignatedTypes(Set.of(ContactPersonFilterStage.ADMINISTRATIVE));
Assert.fail();
} catch (UnmodifiableComponentException e) {
Assert.assertEquals(stage.getDesignateTypes().size(), 0);
@@ -88,7 +86,7 @@ public class ContactPersonFilterStageTest extends BaseDOMTest {
stage = new ContactPersonFilterStage();
stage.destroy();
try {
- stage.setDesignatedTypes(Sets.newHashSet(ContactPersonFilterStage.ADMINISTRATIVE));
+ stage.setDesignatedTypes(Set.of(ContactPersonFilterStage.ADMINISTRATIVE));
Assert.fail();
} catch (DestroyedComponentException e) {
// expected this
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.
More information about the commits
mailing list