Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
14 changed files
with
145 additions
and
145 deletions.
There are no files selected for viewing
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
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
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
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
128 changes: 64 additions & 64 deletions
128
...rser/ast/nodeTypes/NodeWithThrowable.java → ...t/nodeTypes/NodeWithThrownExceptions.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 | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,64 +1,64 @@ | |||
package com.github.javaparser.ast.nodeTypes; | package com.github.javaparser.ast.nodeTypes; | ||
|
|
||
import com.github.javaparser.ast.Node; | import com.github.javaparser.ast.Node; | ||
import com.github.javaparser.ast.NodeList; | import com.github.javaparser.ast.NodeList; | ||
import com.github.javaparser.ast.type.ClassOrInterfaceType; | import com.github.javaparser.ast.type.ClassOrInterfaceType; | ||
import com.github.javaparser.ast.type.ReferenceType; | import com.github.javaparser.ast.type.ReferenceType; | ||
|
|
||
public interface NodeWithThrowable<N extends Node> { | public interface NodeWithThrownExceptions<N extends Node> { | ||
N setThrownTypes(NodeList<ReferenceType<?>> thrownTypes); | N setThrownExceptions(NodeList<ReferenceType<?>> thrownExceptions); | ||
|
|
||
NodeList<ReferenceType<?>> getThrownTypes(); | NodeList<ReferenceType<?>> getThrownExceptions(); | ||
|
|
||
default ReferenceType getThrownType(int i) { | default ReferenceType getThrownException(int i) { | ||
return getThrownTypes().get(i); | return getThrownExceptions().get(i); | ||
} | } | ||
|
|
||
/** | /** | ||
* Adds this type to the throws clause | * Adds this type to the throws clause | ||
* | * | ||
* @param throwType the exception type | * @param throwType the exception type | ||
* @return this | * @return this | ||
*/ | */ | ||
@SuppressWarnings("unchecked") | @SuppressWarnings("unchecked") | ||
default N addThrownType(ReferenceType<?> throwType) { | default N addThrownException(ReferenceType<?> throwType) { | ||
getThrownTypes().add(throwType); | getThrownExceptions().add(throwType); | ||
throwType.setParentNode((Node) this); | throwType.setParentNode((Node) this); | ||
return (N) this; | return (N) this; | ||
} | } | ||
|
|
||
/** | /** | ||
* Adds this class to the throws clause | * Adds this class to the throws clause | ||
* | * | ||
* @param clazz the exception class | * @param clazz the exception class | ||
* @return this | * @return this | ||
*/ | */ | ||
default N addThrownType(Class<? extends Throwable> clazz) { | default N addThrownException(Class<? extends Throwable> clazz) { | ||
((Node) this).tryAddImportToParentCompilationUnit(clazz); | ((Node) this).tryAddImportToParentCompilationUnit(clazz); | ||
return addThrownType(new ClassOrInterfaceType(clazz.getSimpleName())); | return addThrownException(new ClassOrInterfaceType(clazz.getSimpleName())); | ||
} | } | ||
|
|
||
/** | /** | ||
* Check whether this elements throws this exception class. | * Check whether this elements throws this exception class. | ||
* Note that this is simply a text compare of the simple name of the class, | * Note that this is simply a text compare of the simple name of the class, | ||
* no actual type resolution takes place. | * no actual type resolution takes place. | ||
* | * | ||
* @param clazz the class of the exception | * @param clazz the class of the exception | ||
* @return true if found in throws clause, false if not | * @return true if found in throws clause, false if not | ||
*/ | */ | ||
default boolean isThrown(Class<? extends Throwable> clazz) { | default boolean isThrown(Class<? extends Throwable> clazz) { | ||
return isThrown(clazz.getSimpleName()); | return isThrown(clazz.getSimpleName()); | ||
} | } | ||
|
|
||
/** | /** | ||
* Check whether this elements throws this exception class | * Check whether this elements throws this exception class | ||
* Note that this is simply a text compare, | * Note that this is simply a text compare, | ||
* no actual type resolution takes place. | * no actual type resolution takes place. | ||
* | * | ||
* @param throwableName the class of the exception | * @param throwableName the class of the exception | ||
* @return true if found in throws clause, false if not | * @return true if found in throws clause, false if not | ||
*/ | */ | ||
default boolean isThrown(String throwableName) { | default boolean isThrown(String throwableName) { | ||
return getThrownTypes().stream().anyMatch(t -> t.toString().equals(throwableName)); | return getThrownExceptions().stream().anyMatch(t -> t.toString().equals(throwableName)); | ||
} | } | ||
} | } |
Oops, something went wrong.