You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* Matchers reflective elements that have public visibility.
19
+
* Specifically, this matcher only matches elements marked with the keyword {@code public}.
20
+
* <br>
21
+
* This method matches {@link Class} objects or other {@link java.lang.reflect.Member reflective objects}
22
+
* like {@link java.lang.reflect.Field} or {@link java.lang.reflect.Method} used in reflection.
23
+
* Any other kind of object, or {@code null} values, do not match (but will not cause an Exception).
24
+
*
25
+
* @param <T>
26
+
* the type of the object being matched
27
+
* @return a matcher that matches reflective elements with exactly the given level of visibility
28
+
*/
29
+
@SuppressWarnings("unchecked")
30
+
publicstatic <T> Matcher<T> isPublic()
31
+
{
32
+
// Each matcher is stateless and can match any type (the generic <T> is for type safety at the use site),
33
+
// so it's fine to cast the non-reifiable generic type here at runtime and re-use the same instance.
34
+
return (Matcher<T>) PUBLIC;
35
+
}
36
+
37
+
/**
38
+
* Matchers reflective elements that have protected visibility.
39
+
* Specifically, this matcher only matches elements marked with the keyword {@code protected}; it does NOT match public or private elements.
40
+
* <br>
41
+
* This method matches {@link Class} objects or other {@link java.lang.reflect.Member reflective objects}
42
+
* like {@link java.lang.reflect.Field} or {@link java.lang.reflect.Method} used in reflection.
43
+
* Any other kind of object, or {@code null} values, do not match (but will not cause an Exception).
44
+
*
45
+
* @param <T>
46
+
* the type of the object being matched
47
+
* @return a matcher that matches reflective elements with exactly the given level of visibility
48
+
*/
49
+
@SuppressWarnings("unchecked")
50
+
publicstatic <T> Matcher<T> isProtected()
51
+
{
52
+
// Each matcher is stateless and can match any type (the generic <T> is for type safety at the use site),
53
+
// so it's fine to cast the non-reifiable generic type here at runtime and re-use the same instance.
54
+
return (Matcher<T>) PROTECTED;
55
+
}
56
+
57
+
/**
58
+
* Matchers reflective elements that have package-protected visibility.
59
+
* Specifically, this matcher only matches elements not marked with any of the visibility keywords {@code public}, {@code protected}, or {@code private}.
60
+
* <br>
61
+
* This method matches {@link Class} objects or other {@link java.lang.reflect.Member reflective objects}
62
+
* like {@link java.lang.reflect.Field} or {@link java.lang.reflect.Method} used in reflection.
63
+
* Any other kind of object, or {@code null} values, do not match (but will not cause an Exception).
64
+
*
65
+
* @param <T>
66
+
* the type of the object being matched
67
+
* @return a matcher that matches reflective elements with exactly the given level of visibility
68
+
*/
69
+
@SuppressWarnings("unchecked")
70
+
publicstatic <T> Matcher<T> isPackageProtected()
71
+
{
72
+
// Each matcher is stateless and can match any type (the generic <T> is for type safety at the use site),
73
+
// so it's fine to cast the non-reifiable generic type here at runtime and re-use the same instance.
74
+
return (Matcher<T>) PACKAGE_PROTECTED;
75
+
}
76
+
77
+
/**
78
+
* Matchers reflective elements that have private visibility.
79
+
* Specifically, this matcher only matches elements marked with the keyword {@link private}.
80
+
* <br>
81
+
* This method matches {@link Class} objects or other {@link java.lang.reflect.Member reflective objects}
82
+
* like {@link java.lang.reflect.Field} or {@link java.lang.reflect.Method} used in reflection.
83
+
* Any other kind of object, or {@code null} values, do not match (but will not cause an Exception).
84
+
*
85
+
* @param <T>
86
+
* the type of the object being matched
87
+
* @return a matcher that matches reflective elements with exactly the given level of visibility
88
+
*/
89
+
@SuppressWarnings("unchecked")
90
+
publicstatic <T> Matcher<T> isPrivate()
91
+
{
92
+
// Each matcher is stateless and can match any type (the generic <T> is for type safety at the use site),
93
+
// so it's fine to cast the non-reifiable generic type here at runtime and re-use the same instance.
0 commit comments