Top Description Inners Fields Constructors Methods
org.eclipse.jetty.util

public Class IncludeExcludeSet<T, P>

extends Object
implements Predicate<P>
Class Inheritance
All Implemented Interfaces
java.util.function.Predicate
Known Direct Subclasses
org.eclipse.jetty.util.IncludeExclude
Type Parameters
<T>
The type of element of the set (often a pattern)
<P>
The type of the instance passed to the predicate
Imports
java.util.Arrays, .Collections, .HashSet, .Objects, .Set, java.util.function.Predicate

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.

Nested and Inner Type Summary

Modifier and TypeClass and Description
private static record

Field Summary

Modifier and TypeField and Description
private final Predicate<P>
private final Set<T>
private final Predicate<P>
private final Set<T>

Constructor Summary

AccessConstructor and Description
public
IncludeExcludeSet()

Default constructor over HashSet

public <
The type of Set to use as the backing store
SET extends Set<T>
>
IncludeExcludeSet(Class<SET>
The type of Set 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 a Predicate, then it is also used as the item test for the set, otherwise a SetContainsPredicate instance is created.
setClass
)

Construct an IncludeExclude.

public <
The type of Set to use as the backing store
SET extends Set<T>
>
IncludeExcludeSet(Set<T>
the Set of items that represent the included space
includeSet
,
Predicate<P>
the Predicate for included item testing (null for simple Set#contains(Object) test)
includePredicate
,
Set<T>
the Set of items that represent the excluded space
excludeSet
,
Predicate<P>
the Predicate for excluded item testing (null for simple Set#contains(Object) test)
excludePredicate
)

Construct an IncludeExclude

Method Summary

Modifier and TypeMethod and Description
public IncludeExcludeSet<T, P>
public void
public void
exclude(T element)

public final void
exclude(T... element)

public Set<T>
public Set<T>
public boolean
public boolean
public void
include(T element)

public final void
include(T... element)

public boolean
public Boolean

Returns:

Boolean#TRUE if item is included, Boolean#FALSE if item is excluded, or null if neither
isIncludedAndNotExcluded
(P
The item to test
item
)

Test Included and not Excluded

public int
size()

public boolean

Returns:

true if the input matches an include, and is not excluded.
test
(P
the input argument
t
)

Implements java.util.function.Predicate.test.

Test includes and excludes for match.

public String
toString()

Overrides java.lang.Object.toString.

Returns a string representation of the object.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAllwaitwaitwait

Field Detail

_excludePredicateback to summary
private final Predicate<P> _excludePredicate
_excludesback to summary
private final Set<T> _excludes
_includePredicateback to summary
private final Predicate<P> _includePredicate
_includesback to summary
private final Set<T> _includes

Constructor Detail

IncludeExcludeSetback to summary
public IncludeExcludeSet()

Default constructor over HashSet

IncludeExcludeSetback to summary
public <SET extends Set<T>> IncludeExcludeSet(Class<SET> setClass)

Construct an IncludeExclude.

Parameters
<SET>
The type of Set to use as the backing store
setClass:Class<SET>

The type of Set 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 a Predicate, then it is also used as the item test for the set, otherwise a SetContainsPredicate instance is created.

Annotations
@SuppressWarnings:unchecked, rawtypes
IncludeExcludeSetback to summary
public <SET extends Set<T>> IncludeExcludeSet(Set<T> includeSet, Predicate<P> includePredicate, Set<T> excludeSet, Predicate<P> excludePredicate)

Construct an IncludeExclude

Parameters
<SET>
The type of Set to use as the backing store
includeSet:Set<T>

the Set of items that represent the included space

includePredicate:Predicate<P>

the Predicate for included item testing (null for simple Set#contains(Object) test)

excludeSet:Set<T>

the Set of items that represent the excluded space

excludePredicate:Predicate<P>

the Predicate for excluded item testing (null for simple Set#contains(Object) test)

Annotations
@SuppressWarnings:unused

Method Detail

asImmutableback to summary
public IncludeExcludeSet<T, P> asImmutable()
clearback to summary
public void clear()
excludeback to summary
public void exclude(T element)
excludeback to summary
public final void exclude(T... element)
Annotations
@SafeVarargs
getExcludedback to summary
public Set<T> getExcluded()
getIncludedback to summary
public Set<T> getIncluded()
hasExcludesback to summary
public boolean hasExcludes()
hasIncludesback to summary
public boolean hasIncludes()
includeback to summary
public void include(T element)
includeback to summary
public final void include(T... element)
Annotations
@SafeVarargs
isEmptyback to summary
public boolean isEmpty()
isIncludedAndNotExcludedback to summary
public Boolean isIncludedAndNotExcluded(P item)

Test Included and not Excluded

Parameters
item:P

The item to test

Returns:Boolean

Boolean#TRUE if item is included, Boolean#FALSE if item is excluded, or null if neither

sizeback to summary
public int size()
testback to summary
public boolean test(P t)

Implements java.util.function.Predicate.test.

Test includes and excludes for match.

Excludes always win over includes.

Empty includes means all inputs are allowed.

Parameters
t:P

the input argument

Returns:boolean

true if the input matches an include, and is not excluded.

Annotations
@Override
toStringback to summary
public String toString()

Overrides java.lang.Object.toString.

Doc from java.lang.Object.toString.

Returns a string representation of the object. Satisfying this method's contract implies a non-null result must be returned.

Returns:String

a string representation of the object

Annotations
@Override
org.eclipse.jetty.util back to summary

private final Record IncludeExcludeSet.SetContainsPredicate<T>

extends Record
implements Predicate<T>
Class Inheritance
All Implemented Interfaces
java.util.function.Predicate
Record Components
set:Set<T> 

Field Summary

Modifier and TypeField and Description
private final Set<T>
set

Record Component accessed by set().

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public final boolean
equals(Object
the reference object with which to compare.
o
)

Implements abstract java.lang.Record.equals.

Indicates whether some other object is "equal to" this one.

public final int
hashCode()

Implements abstract java.lang.Record.hashCode.

Returns a hash code value for the record.

public Set<T>
set()

Record Component getter of set.

public boolean
test(T
the input argument
item
)

Implements java.util.function.Predicate.test.

Evaluates this predicate on the given argument.

public String
toString()

Implements abstract java.lang.Record.toString.

Returns a string representation of the record.

Field Detail

setback to summary
private final Set<T> set

Record Component accessed by set().

Constructor Detail

SetContainsPredicateback to summary
private SetContainsPredicate(Set<T> set)

Method Detail

equalsback to summary
public final boolean equals(Object o)

Implements abstract java.lang.Record.equals.

Doc from java.lang.Record.equals.

Indicates whether some other object is "equal to" this one. In addition to the general contract of Object.equals, record classes must further obey the invariant that when a record instance is "copied" by passing the result of the record component accessor methods to the canonical constructor, as follows:

    R copy = new R(r.c1(), r.c2(), ..., r.cn());
then it must be the case that r.equals(copy).
Parameters
o:Object

the reference object with which to compare.

Returns:boolean

true if this record is equal to the argument; false otherwise.

hashCodeback to summary
public final int hashCode()

Implements abstract java.lang.Record.hashCode.

Doc from java.lang.Record.hashCode.

Returns a hash code value for the record. Obeys the general contract of Object.hashCode. For records, hashing behavior is constrained by the refined contract of Record.equals, so that any two records created from the same components must have the same hash code.

Returns:int

a hash code value for this record.

setback to summary
public Set<T> set()

Record Component getter of set.

testback to summary
public boolean test(T item)

Implements java.util.function.Predicate.test.

Doc from java.util.function.Predicate.test.

Evaluates this predicate on the given argument.

Parameters
item:T

the input argument

Returns:boolean

true if the input argument matches the predicate, otherwise false

Annotations
@Override
toStringback to summary
public String toString()

Implements abstract java.lang.Record.toString.

Doc from java.lang.Record.toString.

Returns a string representation of the record. In accordance with the general contract of Object#toString(), the toString method returns a string that "textually represents" this record. The result should be a concise but informative representation that is easy for a person to read.

In addition to this general contract, record classes must further participate in the invariant that any two records which are equal must produce equal strings. This invariant is necessarily relaxed in the rare case where corresponding equal component values might fail to produce equal strings for themselves.

Returns:String

a string representation of the object.

Annotations
@Override