@Test public void testGenerateClassCheckedExceptionWithNoInheritance() { AST ast = AST.newAST(AST.JLS3); CompilationUnit cu = ast.newCompilationUnit(); TypeDeclaration typeDeclaration = exceptionGenerator.generateClass( clazz, ast, cu); assertEquals(typeDeclaration.toString(), "public class CompanyException extends Exception {\n}\n"); }
@SuppressWarnings("unchecked") public TypeDeclaration generateClass(Classifier clazz, AST ast, CompilationUnit cu) { String className = getClassName(clazz); TypeDeclaration td = ast.newTypeDeclaration(); td.setInterface(false); td.modifiers().add( ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); td.setName(ast.newSimpleName(className)); generateClassInheritance(clazz, ast, td); generateClassTemplateParams(clazz, ast, td); cu.types().add(td); return td; }
ExceptionGenerator { @SuppressWarnings("unchecked") public TypeDeclaration generateClass(Classifier clazz, AST ast, CompilationUnit cu) { String className = getClassName(clazz); TypeDeclaration td = ast.newTypeDeclaration(); td.setInterface(false); td.modifiers().add( ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); td.setName(ast.newSimpleName(className)); generateClassInheritance(clazz, ast, td); generateClassTemplateParams(clazz, ast, td); cu.types().add(td); return td; } }
ExceptionGenerator { @SuppressWarnings("unchecked") public TypeDeclaration generateClass(Classifier clazz, AST ast, CompilationUnit cu) { String className = getClassName(clazz); TypeDeclaration td = ast.newTypeDeclaration(); td.setInterface(false); td.modifiers().add( ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); td.setName(ast.newSimpleName(className)); generateClassInheritance(clazz, ast, td); generateClassTemplateParams(clazz, ast, td); cu.types().add(td); return td; }  }
ExceptionGenerator { @SuppressWarnings("unchecked") public TypeDeclaration generateClass(Classifier clazz, AST ast, CompilationUnit cu) { String className = getClassName(clazz); TypeDeclaration td = ast.newTypeDeclaration(); td.setInterface(false); td.modifiers().add( ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); td.setName(ast.newSimpleName(className)); generateClassInheritance(clazz, ast, td); generateClassTemplateParams(clazz, ast, td); cu.types().add(td); return td; }  void setCheckedException(boolean isCheckedException); CompilationUnit generateCheckedException(Classifier clazz,
			String sourceDirectoryPackageName); CompilationUnit generateUncheckedException(Classifier clazz,
			String sourceDirectoryPackageName); @SuppressWarnings("unchecked") void generateSerialVersionUID(Classifier clazz, AST ast,
			TypeDeclaration td); @SuppressWarnings("unchecked") TypeDeclaration generateClass(Classifier clazz, AST ast,
			CompilationUnit cu); void generateConstructors(Classifier clazz, AST ast,
			TypeDeclaration td); @SuppressWarnings("unchecked") void generateConstructorWithParams(Classifier clazz, AST ast,
			TypeDeclaration td, String[] varTypes, String[] varNames); }
ExceptionGenerator { @SuppressWarnings("unchecked") public TypeDeclaration generateClass(Classifier clazz, AST ast, CompilationUnit cu) { String className = getClassName(clazz); TypeDeclaration td = ast.newTypeDeclaration(); td.setInterface(false); td.modifiers().add( ast.newModifier(Modifier.ModifierKeyword.PUBLIC_KEYWORD)); td.setName(ast.newSimpleName(className)); generateClassInheritance(clazz, ast, td); generateClassTemplateParams(clazz, ast, td); cu.types().add(td); return td; }  void setCheckedException(boolean isCheckedException); CompilationUnit generateCheckedException(Classifier clazz,
			String sourceDirectoryPackageName); CompilationUnit generateUncheckedException(Classifier clazz,
			String sourceDirectoryPackageName); @SuppressWarnings("unchecked") void generateSerialVersionUID(Classifier clazz, AST ast,
			TypeDeclaration td); @SuppressWarnings("unchecked") TypeDeclaration generateClass(Classifier clazz, AST ast,
			CompilationUnit cu); void generateConstructors(Classifier clazz, AST ast,
			TypeDeclaration td); @SuppressWarnings("unchecked") void generateConstructorWithParams(Classifier clazz, AST ast,
			TypeDeclaration td, String[] varTypes, String[] varNames);  }