GClass { public GMethod getMethod(String name, Object... args) { name = Interpolate.string(name, args); if (name.indexOf('(') == -1) { for (GMethod method : this.methods) { if (method.getName().equals(name)) { return method; } } GMethod method = new GMethod(this, name); this.methods.add(method); return method; } else { String typesAndNames = this.stripAndImportPackageIfPossible(name.substring(name.indexOf('(') + 1, name.length() - 1)); name = name.substring(0, name.indexOf('(')); for (GMethod method : this.methods) { if (method.getName().equals(name) && method.hasSameArguments(typesAndNames)) { return method; } } GMethod method = new GMethod(this, name); method.arguments(typesAndNames); this.methods.add(method); return method; } } GClass(String fullClassName);  GClass(GDirectory directory, String fullClassName); GDirectory getDirectory(); GClass setEnum(); GClass setInterface(); GClass addEnumValue(String value, Object... args); GClass addGetterSetter(String type, String name); boolean isSameClass(String fullNameWithOrWithoutGenerics); GClass getInnerClass(String name, Object... args); GClass notStatic(); GMethod getConstructor(String... typeAndNames); GMethod getConstructor(Argument arg0, Argument... _args); GMethod getConstructor(List<Argument> _args); boolean hasMethod(String name); GMethod getMethod(String name, Object... args); GMethod getMethod(String name, Argument arg0, Argument... _args); GMethod getMethod(String name, List<Argument> _args); GField getField(String name, Object... args); String toCode(); GClass setAbstract(); GClass setPackagePrivate(); GClass setPrivate(); GClass setAccess(Access access); GClass setAnonymous(); GClass addImports(Class<?>... types); GClass addImports(String... importClassNames); String getBaseClassName(); String getBaseQualifiedClassName(); GClass baseClass(Class<?> type); GClass baseClassName(String baseClassName, Object... args); String stripAndImportPackageIfPossible(String fullClassName); List<GMethod> getConstructors(); String toString(); String getPackageName(); String getSimpleName(); String getFullName(); String getFileName(); GClass implementsInterface(Class<?> interfaceClass); GClass implementsInterface(String interfaceFullName, Object... args); GClass addAnnotation(String annotation, Object... args); GClass addEquals(); GClass addEquals(String... fieldNames); GClass addEquals(Collection<String> fieldNames); GClass addHashCode(); GClass addHashCode(String... fieldNames); GClass addHashCode(Collection<String> fieldNames); GClass addToString(); GClass addToString(String... fieldNames); GClass addToString(Collection<String> fieldNames); final StringBuilderr staticInitializer; }
@Test public void testGetMethodMatchesArguments() { GClass gc = new GClass("Foo"); GMethod m1 = gc.getMethod("foo(java.lang.String arg)"); GMethod m2 = gc.getMethod("foo(java.lang.String arg)"); Assert.assertSame(m1, m2); GMethod m3 = gc.getMethod("foo(String arg1)"); Assert.assertSame(m1, m3); GMethod m4 = gc.getMethod("bar()"); GMethod m5 = gc.getMethod("bar()"); Assert.assertSame(m4, m5); }