Class ClassMatcher
- Direct Known Subclasses:
ClassMatcher, ClassMatcher, ClassMatcher
A matcher for classes based on package and/or location and/or module/
Performs pattern matching of a class against a set of pattern entries. A class pattern is a string of one of the forms:
- 'org.package.SomeClass' will match a specific class
- 'org.package.' will match a specific package hierarchy
- 'org.package.SomeClass$NestedClass ' will match a nested class exactly otherwise. Nested classes are matched by their containing class. (eg. org.example.MyClass matches org.example.MyClass$AnyNestedClass)
- 'file:///some/location/' - A file system directory from which the class was loaded
- 'file:///some/location.jar' - The URI of a jar file from which the class was loaded
- 'jrt:/modulename' - A Java9 module name
- Any of the above patterns preceded by '-' will exclude rather than include the match.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic classstatic classstatic classstatic classstatic classprotected static interfaceClassMatcher.Constructor<T extends ClassMatcher>Deprecated.static class -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final Map<String, ClassMatcher.Entry> protected final IncludeExcludeSet<ClassMatcher.Entry, URI> protected final IncludeExcludeSet<ClassMatcher.Entry, String> -
Constructor Summary
ConstructorsModifierConstructorDescriptionClassMatcher(String pattern) ClassMatcher(String... patterns) protectedClassMatcher(Map<String, ClassMatcher.Entry> entries, IncludeExcludeSet<ClassMatcher.Entry, String> patterns, IncludeExcludeSet<ClassMatcher.Entry, URI> locations) ClassMatcher(ClassMatcher patterns) -
Method Summary
Modifier and TypeMethodDescriptionbooleanbooleanprotected booleanadd(ClassMatcher.Entry entry) voidclear()booleanbooleanString[]String[]String[]booleanbooleaniterator()booleanMatch the class name against the patternbooleanMatch the class name against the patternbooleanprotected ClassMatcher.Entryprotected ClassMatcher.Entrybooleanintsize()protected static <T extends ClassMatcher>
Twrap(ClassMatcher matcher, ClassMatcher.Constructor<T> constructor) Deprecated.Methods inherited from class AbstractSet
equals, hashCode, removeAllMethods inherited from class AbstractCollection
addAll, contains, containsAll, isEmpty, retainAll, toArray, toArray, toStringMethods inherited from interface Collection
parallelStream, removeIf, stream, toArrayMethods inherited from interface Set
addAll, contains, containsAll, isEmpty, retainAll, spliterator, toArray, toArray
-
Field Details
-
_entries
-
_patterns
-
_locations
-
-
Constructor Details
-
ClassMatcher
protected ClassMatcher(Map<String, ClassMatcher.Entry> entries, IncludeExcludeSet<ClassMatcher.Entry, String> patterns, IncludeExcludeSet<ClassMatcher.Entry, URI> locations) -
ClassMatcher
public ClassMatcher() -
ClassMatcher
-
ClassMatcher
-
ClassMatcher
-
-
Method Details
-
wrap
@Deprecated protected static <T extends ClassMatcher> T wrap(ClassMatcher matcher, ClassMatcher.Constructor<T> constructor) Deprecated.useClassMatcherdirectly.Wrap an instance of aClassMatcherusing a constructor of an extendedClassMatcherthat needs access to the internal fields of the passed matcher.- Type Parameters:
T- The type of the API specific wrapper- Parameters:
matcher- The matcher to wrapconstructor- The constructor to build the API specific wrapper- Returns:
- A wrapper of the
matcher, sharing internal state.
-
asImmutable
-
include
-
include
-
exclude
-
exclude
-
add
- Specified by:
addin interfaceCollection<String>- Specified by:
addin interfaceSet<String>- Overrides:
addin classAbstractCollection<String>
-
add
-
add
-
newEntry
-
newEntry
-
remove
- Specified by:
removein interfaceCollection<String>- Specified by:
removein interfaceSet<String>- Overrides:
removein classAbstractCollection<String>
-
clear
public void clear()- Specified by:
clearin interfaceCollection<String>- Specified by:
clearin interfaceSet<String>- Overrides:
clearin classAbstractCollection<String>
-
iterator
-
size
public int size()- Specified by:
sizein interfaceCollection<String>- Specified by:
sizein interfaceSet<String>- Specified by:
sizein classAbstractCollection<String>
-
getPatterns
- Returns:
- array of classpath patterns
-
getInclusions
- Returns:
- array of inclusive classpath patterns
-
getExclusions
- Returns:
- array of excluded classpath patterns (without '-' prefix)
-
match
Match the class name against the pattern- Parameters:
name- name of the class to match- Returns:
- true if class matches the pattern
-
match
Match the class name against the pattern- Parameters:
clazz- A class to try to match- Returns:
- true if class matches the pattern
-
match
-
ClassMatcherdirectly.