Package org.opensaml.saml.metadata.resolver.filter.impl

# Class PredicateFilter

java.lang.Object
net.shibboleth.shared.component.AbstractInitializableComponent
org.opensaml.saml.metadata.resolver.filter.AbstractMetadataFilter
org.opensaml.saml.metadata.resolver.filter.impl.PredicateFilter

All Implemented Interfaces:
  `Component`, `DestructableComponent`, `InitializableComponent`, `MetadataFilter`

public class PredicateFilter extends AbstractMetadataFilter
A filter that removes any `EntityDescriptor` that does or does not match a `Predicate`, thus an include or exclude policy.

If an `EntitiesDescriptor` does not contain any children after filtering it may, optionally, be removed as well. If the root element of the metadata document is an @link EntitiesDescriptor}, it will never be removed, regardless of of whether it still has children.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static enum`
`PredicateFilter.Direction`
Whether matching means to include or exclude an entity.

## Field Summary

Fields
Modifier and Type
Field
Description
`private final Predicate<EntityDescriptor>`
`condition`
Matching predicate.
`private final PredicateFilter.Direction`
`direction`
Whether matching means to include or exclude an entity.
`private final org.slf4j.Logger`
`log`
Class logger.
`private boolean`
`removeEmptyEntitiesDescriptors`
Whether to keep entities descriptors that contain no entity descriptors; default value: true.

## Constructor Summary

Constructors
Constructor
Description
`PredicateFilter(PredicateFilter.Direction dir, Predicate<EntityDescriptor> theCondition)`
Constructor.

## Method Summary

Modifier and Type
Method
Description
`XMLObject`
`filter(XMLObject metadata, MetadataFilterContext context)`
Filters the given metadata, perhaps to remove elements that are not wanted.
`protected void`
`filterEntitiesDescriptor(EntitiesDescriptor descriptor)`
Filters entities descriptor.
`Predicate<EntityDescriptor>`
`getCondition()`
Get the predicate to be applied.
`PredicateFilter.Direction`
`getDirection()`
Get the direction of filtering.
`boolean`
`getRemoveEmptyEntitiesDescriptors()`
Get whether to remove an entities descriptor if it does not contain any entity descriptor or entities descriptors.
`void`
`setRemoveEmptyEntitiesDescriptors(boolean remove)`
Set whether to remove an entities descriptor if it does not contain any entity descriptor or entities descriptors.

### Methods inherited from class org.opensaml.saml.metadata.resolver.filter.AbstractMetadataFilter

`getType, setType`

### Methods inherited from class net.shibboleth.shared.component.AbstractInitializableComponent

`checkComponentActive, checkSetterPreconditions, destroy, doDestroy, doInitialize, ifDestroyedThrowDestroyedComponentException, ifInitializedThrowUnmodifiabledComponentException, ifNotInitializedThrowUninitializedComponentException, initialize, isDestroyed, isInitialized`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Field Details

### log

@Nonnull private final org.slf4j.Logger log
Class logger.

### direction

@Nonnull private final PredicateFilter.Direction direction
Whether matching means to include or exclude an entity.

### condition

@Nonnull private final Predicate<EntityDescriptor> condition
Matching predicate.

### removeEmptyEntitiesDescriptors

private boolean removeEmptyEntitiesDescriptors
Whether to keep entities descriptors that contain no entity descriptors; default value: true.

## Constructor Details

### PredicateFilter

public PredicateFilter(@Nonnull PredicateFilter.Direction dir, @Nonnull Predicate<EntityDescriptor> theCondition)
Constructor.

Parameters:
  `dir` - whether to apply an include or an exclude policy
  `theCondition` - the predicate to apply to determine inclusion or exclusion

## Method Details

### getDirection

@Nonnull public PredicateFilter.Direction getDirection()
Get the direction of filtering.

Returns:
  filtering direction

### getCondition

@Nonnull public Predicate<EntityDescriptor> getCondition()
Get the predicate to be applied.

Returns:
  the predicate to be applied

### getRemoveEmptyEntitiesDescriptors

public boolean getRemoveEmptyEntitiesDescriptors()
Get whether to remove an entities descriptor if it does not contain any entity descriptor or entities descriptors.

Returns:
  whether to remove an entities descriptor if it does not contain any entity descriptor or entities descriptors

### setRemoveEmptyEntitiesDescriptors

public void setRemoveEmptyEntitiesDescriptors(boolean remove)
Set whether to remove an entities descriptor if it does not contain any entity descriptor or entities descriptors.

Parameters:
  `remove` - whether to remove an entities descriptor if it does not contain any entity descriptor or entities descriptors

### filter

@Nullable public XMLObject filter(@Nullable XMLObject metadata, @Nonnull MetadataFilterContext context) throws FilterException
Filters the given metadata, perhaps to remove elements that are not wanted.

Parameters:
  `metadata` - the metadata to be filtered.
  `context` - the metadata filter context
Returns:
  the filtered XMLObject, which may or may not be the same as the XMLObject instance passed in to the method. Maybe be null, for example if the top-level element was removed by the filter.
Throws:
  `FilterException` - thrown if an error occurs during the filtering process

### filterEntitiesDescriptor

protected void filterEntitiesDescriptor(@Nonnull EntitiesDescriptor descriptor)
Filters entities descriptor.

Parameters:
  `descriptor` - entities descriptor to filter