1b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpackage org.junit.runner; 2b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 3b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.io.Serializable; 4b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.lang.annotation.Annotation; 5b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.util.ArrayList; 6b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.util.Arrays; 7b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.util.Collection; 8b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.util.regex.Matcher; 9b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotimport java.util.regex.Pattern; 10b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 11b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot/** 12b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * <p>A <code>Description</code> describes a test which is to be run or has been run. <code>Descriptions</code> 13b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * can be atomic (a single test) or compound (containing children tests). <code>Descriptions</code> are used 14b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * to provide feedback about the tests that are about to run (for example, the tree view 15b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * visible in many IDEs) or tests that have been run (for example, the failures view).</p> 16b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * 17b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * <p><code>Descriptions</code> are implemented as a single class rather than a Composite because 18b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * they are entirely informational. They contain no logic aside from counting their tests.</p> 19b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * 20b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * <p>In the past, we used the raw {@link junit.framework.TestCase}s and {@link junit.framework.TestSuite}s 21b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * to display the tree of tests. This was no longer viable in JUnit 4 because atomic tests no longer have 22b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * a superclass below {@link Object}. We needed a way to pass a class and name together. Description 23b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * emerged from this.</p> 24b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * 25b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @see org.junit.runner.Request 26b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @see org.junit.runner.Runner 27b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 28b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabotpublic class Description implements Serializable { 29b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot private static final long serialVersionUID = 1L; 30b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 31b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 32b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Create a <code>Description</code> named <code>name</code>. 33b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Generally, you will add children to this <code>Description</code>. 34b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @param name the name of the <code>Description</code> 35b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @param annotations 36b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return a <code>Description</code> named <code>name</code> 37b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 38b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public static Description createSuiteDescription(String name, Annotation... annotations) { 39b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot if (name.length() == 0) 40b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot throw new IllegalArgumentException("name must have non-zero length"); 41b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return new Description(name, annotations); 42b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 43b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 44b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 45b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Create a <code>Description</code> of a single test named <code>name</code> in the class <code>clazz</code>. 46b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Generally, this will be a leaf <code>Description</code>. 47b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @param clazz the class of the test 48b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @param name the name of the test (a method name for test annotated with {@link org.junit.Test}) 49b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @param annotations meta-data about the test, for downstream interpreters 50b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return a <code>Description</code> named <code>name</code> 51b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 52b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public static Description createTestDescription(Class<?> clazz, String name, Annotation... annotations) { 53b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return new Description(String.format("%s(%s)", name, clazz.getName()), annotations); 54b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 55b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 56b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 57b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Create a <code>Description</code> of a single test named <code>name</code> in the class <code>clazz</code>. 58b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Generally, this will be a leaf <code>Description</code>. 59b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * (This remains for binary compatibility with clients of JUnit 4.3) 60b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @param clazz the class of the test 61b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @param name the name of the test (a method name for test annotated with {@link org.junit.Test}) 62b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return a <code>Description</code> named <code>name</code> 63b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 64b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public static Description createTestDescription(Class<?> clazz, String name) { 65b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return createTestDescription(clazz, name, new Annotation[0]); 66b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 67b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 68b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 69b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Create a <code>Description</code> named after <code>testClass</code> 70b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @param testClass A {@link Class} containing tests 71b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return a <code>Description</code> of <code>testClass</code> 72b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 73b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public static Description createSuiteDescription(Class<?> testClass) { 74b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return new Description(testClass.getName(), testClass.getAnnotations()); 75b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 76b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 77b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 78b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Describes a Runner which runs no tests 79b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 80b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public static final Description EMPTY= new Description("No Tests"); 81b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 82b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 83b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Describes a step in the test-running mechanism that goes so wrong no 84b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * other description can be used (for example, an exception thrown from a Runner's 85b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * constructor 86b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 87b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public static final Description TEST_MECHANISM= new Description("Test mechanism"); 88b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 89b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot private final ArrayList<Description> fChildren= new ArrayList<Description>(); 90b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot private final String fDisplayName; 91b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 92b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot private final Annotation[] fAnnotations; 93b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 94b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot private Description(final String displayName, Annotation... annotations) { 95b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot fDisplayName= displayName; 96b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot fAnnotations= annotations; 97b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 98b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 99b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 100b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return a user-understandable label 101b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 102b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public String getDisplayName() { 103b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return fDisplayName; 104b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 105b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 106b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 107b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * Add <code>Description</code> as a child of the receiver. 108b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @param description the soon-to-be child. 109b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 110b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public void addChild(Description description) { 111b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot getChildren().add(description); 112b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 113b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 114b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 115b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return the receiver's children, if any 116b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 117b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public ArrayList<Description> getChildren() { 118b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return fChildren; 119b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 120b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 121b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 122b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return <code>true</code> if the receiver is a suite 123b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 124b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public boolean isSuite() { 125b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return !isTest(); 126b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 127b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 128b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 129b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return <code>true</code> if the receiver is an atomic test 130b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 131b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public boolean isTest() { 132b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return getChildren().isEmpty(); 133b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 134b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 135b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 136b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return the total number of atomic tests in the receiver 137b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 138b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public int testCount() { 139b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot if (isTest()) 140b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return 1; 141b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot int result= 0; 142b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot for (Description child : getChildren()) 143b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot result+= child.testCount(); 144b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return result; 145b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 146b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 147b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot @Override 148b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public int hashCode() { 149b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return getDisplayName().hashCode(); 150b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 151b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 152b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot @Override 153b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public boolean equals(Object obj) { 154b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot if (!(obj instanceof Description)) 155b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return false; 156b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot Description d = (Description) obj; 157b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return getDisplayName().equals(d.getDisplayName()); 158b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 159b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 160b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot @Override 161b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public String toString() { 162b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return getDisplayName(); 163b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 164b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 165b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 166b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return true if this is a description of a Runner that runs no tests 167b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 168b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public boolean isEmpty() { 169b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return equals(EMPTY); 170b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 171b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 172b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 173b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return a copy of this description, with no children (on the assumption that some of the 174b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * children will be added back) 175b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 176b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public Description childlessCopy() { 177b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return new Description(fDisplayName, fAnnotations); 178b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 179b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 180b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 181b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return the annotation of type annotationType that is attached to this description node, 182b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * or null if none exists 183b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 184b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public <T extends Annotation> T getAnnotation(Class<T> annotationType) { 185b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot for (Annotation each : fAnnotations) 186b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot if (each.annotationType().equals(annotationType)) 187b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return annotationType.cast(each); 188b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return null; 189b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 190b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 191b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 192b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return all of the annotations attached to this description node 193b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 194b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public Collection<Annotation> getAnnotations() { 195b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return Arrays.asList(fAnnotations); 196b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 197b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 198b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 199b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return If this describes a method invocation, 200b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * the class of the test instance. 201b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 202b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public Class<?> getTestClass() { 203b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot String name= getClassName(); 204b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot if (name == null) 205b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return null; 206b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot try { 207b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return Class.forName(name); 208b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } catch (ClassNotFoundException e) { 209b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return null; 210b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 211b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 212b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 213b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 214b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return If this describes a method invocation, 215b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * the name of the class of the test instance 216b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 217b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public String getClassName() { 218b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot Matcher matcher= methodStringMatcher(); 219b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return matcher.matches() 220b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot ? matcher.group(2) 221b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot : toString(); 222b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 223b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 224b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot /** 225b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * @return If this describes a method invocation, 226b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot * the name of the method (or null if not) 227b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot */ 228b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot public String getMethodName() { 229b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return parseMethod(); 230b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 231b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 232b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot private String parseMethod() { 233b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot Matcher matcher= methodStringMatcher(); 234b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot if (matcher.matches()) 235b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return matcher.group(1); 236b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return null; 237b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 238b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot 239b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot private Matcher methodStringMatcher() { 240b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot return Pattern.compile("(.*)\\((.*)\\)").matcher(toString()); 241b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot } 242b3823db9f1192d8c81345740b3e65bd6738ba55bBrett Chabot}