/** * Matches exactly the system {@link java.lang.ClassLoader}. The returned matcher is a synonym to * a matcher matching {@code ClassLoader.gerSystemClassLoader()}. * * @param <T> The type of the matched object. * @return A matcher that only matches the system class loader. */ public static <T extends ClassLoader> ElementMatcher.Junction<T> isSystemClassLoader() { return new EqualityMatcher<T>(ClassLoader.getSystemClassLoader()); }
/** * Exactly matches a given field as a {@link FieldDescription} in its defined shape. * * @param field The field to match by its description * @param <T> The type of the matched object. * @return An element matcher that exactly matches the given field in its defined shape. */ public static <T extends FieldDescription> ElementMatcher.Junction<T> is(FieldDescription.InDefinedShape field) { return definedField(new EqualityMatcher<FieldDescription.InDefinedShape>(field)); }
/** * Exactly matches a given method or constructor as a {@link MethodDescription} in its defined shape. * * @param method The method to match by its description * @param <T> The type of the matched object. * @return An element matcher that exactly matches the given method or constructor in its defined shape. */ public static <T extends MethodDescription> ElementMatcher.Junction<T> is(MethodDescription.InDefinedShape method) { return definedMethod(new EqualityMatcher<MethodDescription.InDefinedShape>(method)); }
/** * Exactly matches a given parameter as a {@link ParameterDescription} in its defined shape. * * @param parameter The parameter to match by its description * @param <T> The type of the matched object. * @return An element matcher that exactly matches the given parameter in its defined shape. */ public static <T extends ParameterDescription> ElementMatcher.Junction<T> is(ParameterDescription.InDefinedShape parameter) { return definedParameter(new EqualityMatcher<ParameterDescription.InDefinedShape>(parameter)); }
/** * Matches the given value which can also be {@code null} by the {@link java.lang.Object#equals(Object)} method or * by a null-check. * * @param value The value that is to be matched. * @param <T> The type of the matched object. * @return A matcher that matches an exact value. */ public static <T> ElementMatcher.Junction<T> is(Object value) { return value == null ? new NullMatcher<T>() : new EqualityMatcher<T>(value); }
/** * Matches exactly the extension {@link java.lang.ClassLoader}. The returned matcher is a synonym to * a matcher matching {@code ClassLoader.gerSystemClassLoader().getParent()}. * * @param <T> The type of the matched object. * @return A matcher that only matches the extension class loader. */ public static <T extends ClassLoader> ElementMatcher.Junction<T> isExtensionClassLoader() { ClassLoader classLoader = ClassLoader.getSystemClassLoader().getParent(); return classLoader == null // Check if VM supports the extension class loader. ? ElementMatchers.<T>none() : new EqualityMatcher<T>(classLoader); }