Package spoon.reflect.code
Interface CtCase<S>
- Type Parameters:
S
- This type must be assignable from the switch type
- All Superinterfaces:
Cloneable
,CtCodeElement
,CtElement
,CtQueryable
,CtStatement
,CtStatementList
,CtVisitable
,FactoryAccessor
,Iterable<CtStatement>
,Serializable
,SourcePositionHolder
- All Known Implementing Classes:
CtCaseImpl
This code element defines a case within a switch-case.
Example:
int x = 0; switch(x) { case 1: // <-- case statement System.out.println("foo"); }
- See Also:
CtSwitch
-
Method Summary
Modifier and TypeMethodDescriptionaddCaseExpression(CtExpression<S> caseExpression)
Adds case expression.clone()
Clone the element which calls this method in a new object.Gets the case expression.Gets the case expressions.Gets the kind of this case - colon (:) or arrow (->) (Arrow syntax is available as a preview feature since Java 12)setCaseExpression(CtExpression<S> caseExpression)
Sets the case expression.setCaseExpressions(List<CtExpression<S>> caseExpressions)
Sets the case expressions.setCaseKind(CaseKind kind)
Sets the kind of this case - colon (:) or arrow (->) (Arrow syntax is available as a preview feature since Java 12)Methods inherited from interface spoon.reflect.code.CtCodeElement
partiallyEvaluate
Methods inherited from interface spoon.reflect.declaration.CtElement
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
Methods inherited from interface spoon.reflect.visitor.chain.CtQueryable
filterChildren, map, map
Methods inherited from interface spoon.reflect.code.CtStatement
comment, getLabel, insertAfter, insertAfter, insertBefore, insertBefore, setLabel
Methods inherited from interface spoon.reflect.code.CtStatementList
addStatement, addStatement, getLastStatement, getStatement, getStatements, insertAfter, insertAfter, insertBefore, insertBefore, insertBegin, insertBegin, insertEnd, insertEnd, removeStatement, setStatements
Methods inherited from interface spoon.reflect.visitor.CtVisitable
accept
Methods inherited from interface spoon.processing.FactoryAccessor
getFactory, setFactory
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
-
Method Details
-
getCaseExpression
CtExpression<S> getCaseExpression()Gets the case expression. UsegetCaseExpressions()
since Java 12 -
setCaseExpression
Sets the case expression. If set with null, the CtCase will represent a default label. UsesetCaseExpressions(List)
since Java 12 -
getCaseExpressions
List<CtExpression<S>> getCaseExpressions()Gets the case expressions. (Multiple case expressions are available as a preview feature since Java 12) -
setCaseExpressions
Sets the case expressions. If set with null or an empty list, the CtCase will represent a default label. (Multiple case expressions are available as a preview feature since Java 12) -
addCaseExpression
Adds case expression. (Multiple case expressions are available as a preview feature since Java 12) -
getCaseKind
CaseKind getCaseKind()Gets the kind of this case - colon (:) or arrow (->) (Arrow syntax is available as a preview feature since Java 12) -
setCaseKind
Sets the kind of this case - colon (:) or arrow (->) (Arrow syntax is available as a preview feature since Java 12) -
clone
Description copied from interface:CtElement
Clone the element which calls this method in a new object. Note that that references are kept as is, and thus, so if you clone whole classes or methods, some parts of the cloned element (eg executable references) may still point to the initial element. In this case, consider using methodsRefactoring.copyType(CtType)
andRefactoring.copyMethod(CtMethod)
instead which does additional work beyond cloning.- Specified by:
clone
in interfaceCtCodeElement
- Specified by:
clone
in interfaceCtElement
- Specified by:
clone
in interfaceCtStatement
- Specified by:
clone
in interfaceCtStatementList
-