spoon.reflect.code.CtCase Maven / Gradle / Ivy
/*
* SPDX-License-Identifier: (MIT OR CECILL-C)
*
* Copyright (C) 2006-2019 INRIA and contributors
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) of the Cecill-C License (see LICENSE-CECILL-C.txt). You as the user are entitled to choose the terms under which to adopt Spoon.
*/
package spoon.reflect.code;
import spoon.reflect.annotations.PropertyGetter;
import spoon.reflect.annotations.PropertySetter;
import java.util.List;
import static spoon.reflect.path.CtRole.CASE_KIND;
import static spoon.reflect.path.CtRole.EXPRESSION;
/**
* This code element defines a case within a switch-case.
*
* Example:
* int x = 0;
* switch(x) {
* case 1: // <-- case statement
* System.out.println("foo");
* }
*
* @param
* This type must be assignable from the switch type
* @see spoon.reflect.code.CtSwitch
*/
public interface CtCase extends CtStatement, CtStatementList {
/**
* Gets the case expression.
* Use {@link #getCaseExpressions()} since Java 12
*/
@PropertyGetter(role = EXPRESSION)
CtExpression getCaseExpression();
/**
* Sets the case expression. If set with null, the CtCase will represent a default label.
* Use {@link #setCaseExpressions(List)} since Java 12
*/
@PropertySetter(role = EXPRESSION)
> T setCaseExpression(CtExpression caseExpression);
/**
* Gets the case expressions.
* (Multiple case expressions are available as a preview feature since Java 12)
*/
@PropertyGetter(role = EXPRESSION)
List> getCaseExpressions();
/**
* 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)
*/
@PropertySetter(role = EXPRESSION)
> T setCaseExpressions(List> caseExpressions);
/**
* Adds case expression.
* (Multiple case expressions are available as a preview feature since Java 12)
*/
@PropertySetter(role = EXPRESSION)
> T addCaseExpression(CtExpression caseExpression);
/**
* Gets the kind of this case - colon (:) or arrow (->)
* (Arrow syntax is available as a preview feature since Java 12)
*/
@PropertyGetter(role = CASE_KIND)
CaseKind getCaseKind();
/**
* Sets the kind of this case - colon (:) or arrow (->)
* (Arrow syntax is available as a preview feature since Java 12)
*/
@PropertySetter(role = CASE_KIND)
> T setCaseKind(CaseKind kind);
@Override
CtCase clone();
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy