-
Notifications
You must be signed in to change notification settings - Fork 162
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #520 from agoncal/FORGE-2091
FORGE-2091: Being able to create a new Java exception
- Loading branch information
Showing
3 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
parser-java/api/src/main/java/org/jboss/forge/addon/parser/java/ui/JavaExceptionCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/** | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.addon.parser.java.ui; | ||
|
||
import org.jboss.forge.addon.ui.command.UICommand; | ||
|
||
/** | ||
* @author <a href="mailto:antonio.goncalves@gmail.com">Antonio Goncalves</a> | ||
*/ | ||
public interface JavaExceptionCommand extends UICommand | ||
{ | ||
} |
43 changes: 43 additions & 0 deletions
43
...ava/impl/src/main/java/org/jboss/forge/addon/parser/java/ui/JavaExceptionCommandImpl.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* Copyright 2014 Red Hat, Inc. and/or its affiliates. | ||
* | ||
* Licensed under the Eclipse Public License version 1.0, available at | ||
* http://www.eclipse.org/legal/epl-v10.html | ||
*/ | ||
|
||
package org.jboss.forge.addon.parser.java.ui; | ||
|
||
import org.jboss.forge.addon.projects.Project; | ||
import org.jboss.forge.addon.ui.context.UIExecutionContext; | ||
import org.jboss.forge.roaster.model.source.JavaClassSource; | ||
|
||
/** | ||
* @author <a href="mailto:antonio.goncalves@gmail.com">Antonio Goncalves</a> | ||
*/ | ||
public class JavaExceptionCommandImpl extends AbstractJavaSourceCommand<JavaClassSource> implements | ||
JavaExceptionCommand | ||
{ | ||
|
||
@Override | ||
public JavaClassSource decorateSource(UIExecutionContext context, Project project, JavaClassSource source) | ||
throws Exception | ||
{ | ||
source.setSuperType(RuntimeException.class); | ||
source.addMethod().setPublic().setConstructor(true).setBody("super();"); | ||
source.addMethod().setPublic().setConstructor(true).setParameters("String message").setBody("super(message);"); | ||
|
||
return source; | ||
} | ||
|
||
@Override | ||
protected Class<JavaClassSource> getSourceType() | ||
{ | ||
return JavaClassSource.class; | ||
} | ||
|
||
@Override | ||
protected String getType() | ||
{ | ||
return "Exception"; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters