Package org.eclipse.jetty.util
Class IncludeExcludeSet<T,P>
- java.lang.Object
-
- org.eclipse.jetty.util.IncludeExcludeSet<T,P>
-
- Type Parameters:
T
- The type of element of the set (often a pattern)P
- The type of the instance passed to the predicate
- All Implemented Interfaces:
java.util.function.Predicate<P>
- Direct Known Subclasses:
IncludeExclude
public class IncludeExcludeSet<T,P> extends java.lang.Object implements java.util.function.Predicate<P>
Utility class to maintain a set of inclusions and exclusions.Maintains a set of included and excluded elements. The method
test(Object)
will return true IFF the passed object is not in the excluded set AND ( either the included set is empty OR the object is in the included set)The type of the underlying
Set
used may be passed into the constructor, so special sets like Servlet PathMap may be used.
-
-
Constructor Summary
Constructors Constructor Description IncludeExcludeSet()
Default constructor overHashSet
IncludeExcludeSet(java.lang.Class<SET> setClass)
Construct an IncludeExclude.IncludeExcludeSet(java.util.Set<T> includeSet, java.util.function.Predicate<P> includePredicate, java.util.Set<T> excludeSet, java.util.function.Predicate<P> excludePredicate)
Construct an IncludeExclude
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description void
clear()
void
exclude(T element)
void
exclude(T... element)
java.util.Set<T>
getExcluded()
java.util.Set<T>
getIncluded()
boolean
hasExcludes()
boolean
hasIncludes()
void
include(T element)
void
include(T... element)
boolean
isEmpty()
java.lang.Boolean
isIncludedAndNotExcluded(P item)
Test Included and not Excludedstatic <T1,T2>
booleanmatchCombined(T1 item1, IncludeExcludeSet<?,T1> set1, T2 item2, IncludeExcludeSet<?,T2> set2)
Match items in combined IncludeExcludeSets.boolean
matches(P t)
Deprecated.int
size()
boolean
test(P t)
java.lang.String
toString()
-
-
-
Constructor Detail
-
IncludeExcludeSet
public IncludeExcludeSet()
Default constructor overHashSet
-
IncludeExcludeSet
public IncludeExcludeSet(java.lang.Class<SET> setClass)
Construct an IncludeExclude.- Type Parameters:
SET
- The type of a set to use as the backing store- Parameters:
setClass
- The type ofSet
to using internally to hold patterns. Two instances will be created. one for include patterns and one for exclude patters. If the class is also aPredicate
, then it is also used as the item test for the set, otherwise aIncludeExcludeSet.SetContainsPredicate
instance is created.
-
IncludeExcludeSet
public IncludeExcludeSet(java.util.Set<T> includeSet, java.util.function.Predicate<P> includePredicate, java.util.Set<T> excludeSet, java.util.function.Predicate<P> excludePredicate)
Construct an IncludeExclude- Type Parameters:
SET
- The type of a set to use as the backing store- Parameters:
includeSet
- the Set of items that represent the included spaceincludePredicate
- the Predicate for included item testing (null for simpleSet.contains(Object)
test)excludeSet
- the Set of items that represent the excluded spaceexcludePredicate
- the Predicate for excluded item testing (null for simpleSet.contains(Object)
test)
-
-
Method Detail
-
include
public void include(T element)
-
include
public void include(T... element)
-
exclude
public void exclude(T element)
-
exclude
public void exclude(T... element)
-
matches
@Deprecated public boolean matches(P t)
Deprecated.
-
isIncludedAndNotExcluded
public java.lang.Boolean isIncludedAndNotExcluded(P item)
Test Included and not Excluded- Parameters:
item
- The item to test- Returns:
- Boolean.TRUE if item is included, Boolean.FALSE if item is excluded or null if neither
-
hasIncludes
public boolean hasIncludes()
-
hasExcludes
public boolean hasExcludes()
-
size
public int size()
-
getIncluded
public java.util.Set<T> getIncluded()
-
getExcluded
public java.util.Set<T> getExcluded()
-
clear
public void clear()
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
isEmpty
public boolean isEmpty()
-
matchCombined
public static <T1,T2> boolean matchCombined(T1 item1, IncludeExcludeSet<?,T1> set1, T2 item2, IncludeExcludeSet<?,T2> set2)
Match items in combined IncludeExcludeSets.- Type Parameters:
T1
- The type of item1T2
- The type of item2- Parameters:
item1
- The item to match against set1set1
- A IncludeExcludeSet to match item1 againstitem2
- The item to match against set2set2
- A IncludeExcludeSet to match item2 against- Returns:
- True IFF
- Neither item is excluded from their respective sets
- Both sets have no includes OR at least one of the items is included in its respective set
-
-