public interface CtTryWithResource extends CtTry
try
with resource statement.
Example:
// br is the resource try (java.io.BufferedReader br = new java.io.BufferedReader(new java.io.FileReader("/foo"))) { br.readLine(); }
Modifier and Type | Method and Description |
---|---|
<T extends CtTryWithResource> |
addResource(CtLocalVariable<?> resource)
Adds a resource.
|
CtTryWithResource |
clone()
Clone the element which calls this method in a new object.
|
java.util.List<CtLocalVariable<?>> |
getResources()
Gets the auto-closeable resources of this
try . |
boolean |
removeResource(CtLocalVariable<?> resource)
Removes a resource.
|
<T extends CtTryWithResource> |
setResources(java.util.List<CtLocalVariable<?>> resources)
Sets the auto-closeable resources of this
try . |
addCatcher, getBody, getCatchers, getFinalizer, removeCatcher, setCatchers, setFinalizer
comment, getLabel, insertAfter, insertAfter, insertBefore, insertBefore, setLabel
partiallyEvaluate
addAnnotation, addComment, asIterable, delete, descendantIterator, getAllMetadata, getAnnotatedChildren, getAnnotation, getAnnotation, getAnnotations, getComments, getDirectChildren, getDocComment, getElements, getMetadata, getMetadataKeys, getOriginalSourceFragment, getParent, getParent, getParent, getPath, getPosition, getReferencedTypes, getRoleInParent, getShortRepresentation, getValueByRole, hasAnnotation, hasParent, isImplicit, isParentInitialized, prettyprint, putMetadata, removeAnnotation, removeComment, replace, replace, setAllMetadata, setAnnotations, setComments, setDocComment, setImplicit, setParent, setPosition, setPositions, setValueByRole, toString, toStringDebug, updateAllParentsBelow
getFactory, setFactory
accept
filterChildren, map, map
S
setBody
java.util.List<CtLocalVariable<?>> getResources()
try
. Available
from Java 7 with the try-with-resource statement.<T extends CtTryWithResource> T setResources(java.util.List<CtLocalVariable<?>> resources)
try
. Available
from Java 7 with the try-with-resource statement.<T extends CtTryWithResource> T addResource(CtLocalVariable<?> resource)
boolean removeResource(CtLocalVariable<?> resource)
CtTryWithResource clone()
CtElement
Refactoring.copyType(CtType)
and Refactoring.copyMethod(CtMethod)
instead which does additional work beyond cloning.clone
in interface CtCodeElement
clone
in interface CtElement
clone
in interface CtStatement
clone
in interface CtTry
Copyright © 2007–2021 Inria. All rights reserved.