Package com.google.inject.matcher
Class Matchers
- java.lang.Object
-
- com.google.inject.matcher.Matchers
-
public class Matchers extends java.lang.Object
Matcher implementations. Supports matching classes and methods.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description private static class
Matchers.AnnotatedWith
private static class
Matchers.AnnotatedWithType
private static class
Matchers.Any
private static class
Matchers.IdenticalTo
private static class
Matchers.InPackage
private static class
Matchers.InSubpackage
private static class
Matchers.Not<T>
private static class
Matchers.Only
private static class
Matchers.Returns
private static class
Matchers.SubclassesOf
-
Constructor Summary
Constructors Modifier Constructor Description private
Matchers()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Matcher<java.lang.reflect.AnnotatedElement>
annotatedWith(java.lang.annotation.Annotation annotation)
Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.static Matcher<java.lang.reflect.AnnotatedElement>
annotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.static Matcher<java.lang.Object>
any()
Returns a matcher which matches any input.private static void
checkForRuntimeRetention(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
static Matcher<java.lang.Object>
identicalTo(java.lang.Object value)
Returns a matcher which matches only the given object.static Matcher<java.lang.Class>
inPackage(java.lang.Package targetPackage)
Returns a matcher which matches classes in the given package.static Matcher<java.lang.Class>
inSubpackage(java.lang.String targetPackageName)
Returns a matcher which matches classes in the given package and its subpackages.static <T> Matcher<T>
not(Matcher<? super T> p)
Inverts the given matcher.static Matcher<java.lang.Object>
only(java.lang.Object value)
Returns a matcher which matches objects equal to the given object.static Matcher<java.lang.reflect.Method>
returns(Matcher<? super java.lang.Class<?>> returnType)
Returns a matcher which matches methods with matching return types.static Matcher<java.lang.Class>
subclassesOf(java.lang.Class<?> superclass)
Returns a matcher which matches subclasses of the given type (as well as the given type).
-
-
-
Field Detail
-
ANY
private static final Matcher<java.lang.Object> ANY
-
-
Method Detail
-
any
public static Matcher<java.lang.Object> any()
Returns a matcher which matches any input.
-
checkForRuntimeRetention
private static void checkForRuntimeRetention(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
-
annotatedWith
public static Matcher<java.lang.reflect.AnnotatedElement> annotatedWith(java.lang.Class<? extends java.lang.annotation.Annotation> annotationType)
Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.
-
annotatedWith
public static Matcher<java.lang.reflect.AnnotatedElement> annotatedWith(java.lang.annotation.Annotation annotation)
Returns a matcher which matches elements (methods, classes, etc.) with a given annotation.
-
subclassesOf
public static Matcher<java.lang.Class> subclassesOf(java.lang.Class<?> superclass)
Returns a matcher which matches subclasses of the given type (as well as the given type).
-
only
public static Matcher<java.lang.Object> only(java.lang.Object value)
Returns a matcher which matches objects equal to the given object.
-
identicalTo
public static Matcher<java.lang.Object> identicalTo(java.lang.Object value)
Returns a matcher which matches only the given object.
-
inPackage
public static Matcher<java.lang.Class> inPackage(java.lang.Package targetPackage)
Returns a matcher which matches classes in the given package. Packages are specific to their classloader, so classes with the same package name may not have the same package at runtime.
-
inSubpackage
public static Matcher<java.lang.Class> inSubpackage(java.lang.String targetPackageName)
Returns a matcher which matches classes in the given package and its subpackages. UnlikeinPackage()
, this matches classes from any classloader.- Since:
- 2.0
-
-