public class PredicateFilter extends Object implements MetadataFilter
EntityDescriptor
that does or does not match a Predicate
, thus
a whitelist or blacklist.
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.
Modifier and Type | Class and Description |
---|---|
static class |
PredicateFilter.Direction
Whether matching means to include or exclude an entity.
|
Constructor and Description |
---|
PredicateFilter(PredicateFilter.Direction dir,
com.google.common.base.Predicate<EntityDescriptor> theCondition)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
XMLObject |
filter(XMLObject metadata)
Filters the given metadata, perhaps to remove elements that are not wanted.
|
protected void |
filterEntitiesDescriptor(EntitiesDescriptor descriptor)
Filters entities descriptor.
|
com.google.common.base.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.
|
public PredicateFilter(@Nonnull PredicateFilter.Direction dir, @Nonnull com.google.common.base.Predicate<EntityDescriptor> theCondition)
dir
- whether to whitelist or blacklisttheCondition
- the predicate to apply to determine inclusion or exclusion@Nonnull public PredicateFilter.Direction getDirection()
@Nonnull public com.google.common.base.Predicate<EntityDescriptor> getCondition()
public boolean getRemoveEmptyEntitiesDescriptors()
public void setRemoveEmptyEntitiesDescriptors(boolean remove)
remove
- whether to remove an entities descriptor if it does not contain any entity descriptor or entities
descriptorspublic XMLObject filter(@Nullable XMLObject metadata) throws FilterException
filter
in interface MetadataFilter
metadata
- the metadata to be filtered.FilterException
- thrown if an error occurs during the filtering processprotected void filterEntitiesDescriptor(@Nonnull EntitiesDescriptor descriptor)
descriptor
- entities descriptor to filterCopyright © 2016. All rights reserved.