if ( checkCollectionMethods( methodName ) ) { return false; if ( checkCollectionMethods( methodName ) ) { return false; if ( checkCollectionMethods( methodName ) || "get".equals( methodName ) || "listIterator".equals( methodName ) || "lastIndexOf".equals( methodName ) || "indexOf".equals( methodName ) || "subList".equals( methodName ) ) { return false;
public ClassMethodInspector(final Class< ? > clazz, ClassToGenericClassConverter converter) throws IOException { Method[] methods = clazz.getDeclaredMethods(); for ( int i = 0; i < methods.length; i++ ) { Method aMethod = methods[i]; int modifiers = methods[i].getModifiers(); String methodName = aMethod.getName(); if ( isNotGetterOrSetter(aMethod) && isReasonableMethod( clazz, methodName ) && Modifier.isPublic( modifiers ) ) { Class<?>[] listParam = aMethod.getParameterTypes(); MethodInfo info = new MethodInfo(methodName, solveParams(listParam), aMethod.getReturnType(), SuggestionCompletionEngineBuilder .obtainGenericType(aMethod.getGenericReturnType()), converter.translateClassToGenericType(clazz)); this.methods.add(info); } } }
@Test public void testList() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector( List.class, new Converter() ); for ( String s : ext.getMethodNames() ) { assertFalse( "Method " + s + " is not allowed.", allowedMethod( s ) ); } }
ClassMethodInspector methodInspector = new ClassMethodInspector( clazz, this ); List<MethodInfo> methodInfos = methodInspector.getMethodInfos(); for ( MethodInfo mi : methodInfos ) { String genericType = mi.getParametricReturnType();
@Test public void testCollection() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector( Collection.class, new Converter() ); for ( String s : ext.getMethodNames() ) { assertFalse( "Method " + s + " is not allowed.", allowedMethod( s ) ); } }
ClassMethodInspector methodInspector = new ClassMethodInspector( clazz, this ); List<MethodInfo> methodInfos = methodInspector.getMethodInfos(); for ( MethodInfo mi : methodInfos ) { String genericType = mi.getParametricReturnType();
@Test public void testSimpleMethods() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector( SimpleMethods.class, new Converter() ); for ( String s : ext.getMethodNames() ) { assertFalse( "Method " + s + " is not allowed.", allowedMethod( s ) ); } }
public ClassMethodInspector(final Class< ? > clazz, ClassToGenericClassConverter converter) throws IOException { Method[] methods = clazz.getDeclaredMethods(); for ( int i = 0; i < methods.length; i++ ) { Method aMethod = methods[i]; int modifiers = methods[i].getModifiers(); String methodName = aMethod.getName(); if ( isNotGetterOrSetter(aMethod) && isReasonableMethod( clazz, methodName ) && Modifier.isPublic( modifiers ) ) { Class<?>[] listParam = aMethod.getParameterTypes(); MethodInfo info = new MethodInfo(methodName, solveParams(listParam), aMethod.getReturnType(), SuggestionCompletionEngineBuilder .obtainGenericType(aMethod.getGenericReturnType()), converter.translateClassToGenericType(clazz)); this.methods.add(info); } } }
if ( checkCollectionMethods( methodName ) ) { return false; if ( checkCollectionMethods( methodName ) ) { return false; if ( checkCollectionMethods( methodName ) || "get".equals( methodName ) || "listIterator".equals( methodName ) || "lastIndexOf".equals( methodName ) || "indexOf".equals( methodName ) || "subList".equals( methodName ) ) { return false;
@Test public void testMoreThanOneMethodWithTheSameName() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector( MoreThanOneMethodWithTheSameName.class, new Converter() ); for ( String s : ext.getMethodNames() ) { assertFalse( "Method " + s + " is not allowed.", allowedMethod( s ) ); } }
@Test public void testSet() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector( Set.class, new Converter() ); for ( String s : ext.getMethodNames() ) { assertFalse( "Method " + s + " is not allowed.", allowedMethod( s ) ); } }
@Test public void testMap() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector( Map.class, new Converter() ); for ( String s : ext.getMethodNames() ) { assertFalse( "Method " + s + " is not allowed.", allowedMethod( s ) ); } }
@Test public void testMyMap() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector( MyMap.class, new Converter() ); for ( String s : ext.getMethodNames() ) { assertFalse( "Method " + s + " is not allowed.", allowedMethod( s ) ); } }
@Test public void testArrayList() throws Exception { final ClassMethodInspector ext = new ClassMethodInspector( ArrayList.class, new Converter() ); for ( String s : ext.getMethodNames() ) { assertFalse( "Method " + s + " is not allowed.", allowedMethod( s ) ); } }