public class WildcardClassFilter extends AbstractBaseClassFilter implements Serializable
This filter selects classes one or more wildcards. Testing is case-sensitive by default, but this can be configured.
The wildcard matcher uses the characters '?' and '*' to represent a single or multiple characters. This is the same as often found on Dos/Unix command lines.
For example:
Class<?> clazz = org.xenei.junit.contract.filter.ClassFilter.class;
ClassFilter filter = new WildcardClassFilter("*.filter.*");
if (filter.accept(clazz)) {
System.out.println("it works");
}
ClassFilter.UtilNO_ARGSABSTRACT, ANNOTATION, FALSE, INTERFACE, TRUE| Constructor and Description |
|---|
WildcardClassFilter(Case caseSensitivity,
Collection<String> wildcards)
Construct a new wildcard filter for a collection of wildcards specifying
case-sensitivity.
|
WildcardClassFilter(Case caseSensitivity,
String... wildcards)
Construct a new wildcard filter for an array of wildcards specifying
case-sensitivity.
|
WildcardClassFilter(Case caseSensitivity,
String wildcard)
Construct a new wildcard filter for a single wildcard specifying
case-sensitivity.
|
WildcardClassFilter(Collection<String> wildcards)
Construct a new case-sensitive wildcard filter for a collection of
wildcards.
|
WildcardClassFilter(String... wildcards)
Construct a new case-sensitive wildcard filter for an array of wildcards.
|
WildcardClassFilter(String wildcard)
Construct a new case-sensitive wildcard filter for a single wildcard.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(Class<?> clazz)
Accept a class.
|
boolean |
accept(String className)
Accept a class name.
|
void |
addWildcard(String wildcard)
Add a single wildcard string to the filter.
|
void |
addWildCards(Collection<String> wildcards)
Add a collection of wild card strings to the filter
|
void |
addWildCards(String... wildcards)
Add an array of wild card strings to the filter
|
String[] |
args()
Get the arguments for the function.
|
static String |
makeRegex(String wildcard)
Convert the wildcard string into a regex string.
|
String |
toString()
Provide a String representation of this file filter.
|
filter, filterNames, funcNamepublic WildcardClassFilter(String wildcard)
wildcard - the wildcard to matchIllegalArgumentException - if the pattern is nullpublic WildcardClassFilter(Case caseSensitivity, String wildcard)
wildcard - the wildcard to match, not nullcaseSensitivity - how to handle case sensitivity, null means case-sensitiveIllegalArgumentException - if the pattern is nullpublic WildcardClassFilter(String... wildcards)
The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.
wildcards - the array of wildcards to matchIllegalArgumentException - if the pattern array is nullpublic WildcardClassFilter(Case caseSensitivity, String... wildcards)
The array is not cloned, so could be changed after constructing the instance. This would be inadvisable however.
wildcards - the array of wildcards to match, not nullcaseSensitivity - how to handle case sensitivity, null means case-sensitiveIllegalArgumentException - if the pattern array is nullpublic WildcardClassFilter(Collection<String> wildcards)
wildcards - the list of wildcards to match, not nullIllegalArgumentException - if the pattern list is nullClassCastException - if the list does not contain Stringspublic WildcardClassFilter(Case caseSensitivity, Collection<String> wildcards)
wildcards - the list of wildcards to match, not nullcaseSensitivity - how to handle case sensitivity, null means case-sensitiveIllegalArgumentException - if the pattern list is nullClassCastException - if the list does not contain Stringspublic void addWildCards(Collection<String> wildcards)
wildcards - The list of wildcard strings.IllegalArgumentException - if the list is null or if any string within the list is null.public void addWildCards(String... wildcards)
wildcards - The array of wildcard strings.IllegalArgumentException - if the array is null or if any string within the list is
null.public void addWildcard(String wildcard)
wildcard - the string to add.IllegalArgumentException - if the wildcard is null.public String toString()
toString in class AbstractBaseClassFilterpublic static String makeRegex(String wildcard)
wildcard - The wild card string to convert.public boolean accept(Class<?> clazz)
accept in interface ClassFilterclazz - the class to accept.public boolean accept(String className)
accept in interface ClassFilterclassName - the class name to accept.public String[] args()
args in interface ClassFilterCopyright © 2013-2016 XENEI.com. All Rights Reserved.