public class SignatureParser
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
static @Regex(value=0) java.lang.String |
DOT_DELIMITED_IDS
Regex to match a sequence of identifiers (or
<init> ) separated by periods. |
static @Regex(value=0) java.lang.String |
ID_STRING
Regex for Java identifiers.
|
private static java.util.regex.Pattern |
SIGNATURE_PATTERN
Naive regex to match a method signature consisting of a fully-qualified method name followed by
anything in parentheses.
|
Constructor and Description |
---|
SignatureParser() |
Modifier and Type | Method and Description |
---|---|
static java.lang.reflect.AccessibleObject |
parse(java.lang.String signature,
AccessibilityPredicate accessibility,
ReflectionPredicate reflectionPredicate)
Parses a fully-qualified signature and returns the corresponding
java.lang.reflect.AccessibleObject . |
public static final @Regex(value=0) java.lang.String ID_STRING
public static final @Regex(value=0) java.lang.String DOT_DELIMITED_IDS
<init>
) separated by periods. Corresponds
to package names, fully-qualified classnames, or method names with fully-qualified classname.private static final java.util.regex.Pattern SIGNATURE_PATTERN
Capturing group 1 matches the fully-qualified method name, and capturing group 2 matches the contents of the parentheses.
public static java.lang.reflect.AccessibleObject parse(java.lang.String signature, AccessibilityPredicate accessibility, ReflectionPredicate reflectionPredicate) throws SignatureParseException, FailedPredicateException
java.lang.reflect.AccessibleObject
.
A signature is expected to have the form
package-name.classname.method-name(argument-list)
for a method,
package-name.classname.<init>(argument-list)
or package-name.classname(argument-list)
for a constructor.
where package-name
is a period-separated list of identifiers, and argument-list
is a comma-separated (spaces-allowed) list of fully-qualified Java raw types.
Array types have the format element-type[]
.
signature
- the string to parse: a signature string for a method or constructor, in the
above formataccessibility
- the predicate for determining whether the method or constructor is
accessiblereflectionPredicate
- the predicate for checking reflection policyAccessibleObject
for the method or constructor represented by the stringjava.lang.IllegalArgumentException
- if the string does not have the format of a signatureSignatureParseException
- if the signature is not fully-qualified, or the class, an
argument type, or the method or constructor is not found using reflectionFailedPredicateException
- if the accessibility or reflection predicate returns false on
the class or the method or constructor