src/jdk.compiler/share/classes/com/sun/source/tree/CaseTree.java
branchJDK-8226585-branch
changeset 58440 4c8a6d1d066c
parent 58109 ee07de0d2c16
equal deleted inserted replaced
58342:ebb1ff3d6707 58440:4c8a6d1d066c
    53      * @return the expression for the case, or null
    53      * @return the expression for the case, or null
    54      */
    54      */
    55     ExpressionTree getExpression();
    55     ExpressionTree getExpression();
    56 
    56 
    57     /**
    57     /**
       
    58      * {@preview Associated with switch expressions, a preview feature of
       
    59      *           the Java language.
       
    60      *
       
    61      *           This method is associated with <i>switch expressions</i>, a preview
       
    62      *           feature of the Java language. Preview features
       
    63      *           may be removed in a future release, or upgraded to permanent
       
    64      *           features of the Java language.}
       
    65      *
    58      * Returns the labels for this case.
    66      * Returns the labels for this case.
    59      * For default case, returns an empty list.
    67      * For default case, returns an empty list.
    60      *
    68      *
    61      * @return labels for this case
    69      * @return labels for this case
    62      * @since 12
    70      * @since 12
    76      * @return the statements labeled by the case or null
    84      * @return the statements labeled by the case or null
    77      */
    85      */
    78     List<? extends StatementTree> getStatements();
    86     List<? extends StatementTree> getStatements();
    79 
    87 
    80     /**
    88     /**
       
    89      * {@preview Associated with switch expressions, a preview feature of
       
    90      *           the Java language.
       
    91      *
       
    92      *           This method is associated with <i>switch expressions</i>, a preview
       
    93      *           feature of the Java language. Preview features
       
    94      *           may be removed in a future release, or upgraded to permanent
       
    95      *           features of the Java language.}
       
    96      *
    81      * For case with kind {@linkplain CaseKind#RULE},
    97      * For case with kind {@linkplain CaseKind#RULE},
    82      * returns the statement or expression after the arrow.
    98      * returns the statement or expression after the arrow.
    83      * Returns {@code null} for case with kind
    99      * Returns {@code null} for case with kind
    84      * {@linkplain CaseKind#STATEMENT}.
   100      * {@linkplain CaseKind#STATEMENT}.
    85      *
   101      *
    86      * @return case value or null
   102      * @return case value or null
    87      * @since 12
   103      * @since 12
    88      *
       
    89      * @preview This method is modeling a rule case,
       
    90      * which is part of a preview feature and may be removed
       
    91      * if the preview feature is removed.
       
    92      */
   104      */
    93     @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
   105     @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
    94     public default Tree getBody() {
   106     public default Tree getBody() {
    95         return null;
   107         return null;
    96     }
   108     }
    97 
   109 
    98     /**
   110     /**
       
   111      * {@preview Associated with switch expressions, a preview feature of
       
   112      *           the Java language.
       
   113      *
       
   114      *           This method is associated with <i>switch expressions</i>, a preview
       
   115      *           feature of the Java language. Preview features
       
   116      *           may be removed in a future release, or upgraded to permanent
       
   117      *           features of the Java language.}
       
   118      *
    99      * Returns the kind of this case.
   119      * Returns the kind of this case.
   100      *
   120      *
   101      * @return the kind of this case
   121      * @return the kind of this case
   102      * @since 12
   122      * @since 12
   103      *
       
   104      * @preview This method is used to model a rule case,
       
   105      * which is part of a preview feature and may be removed
       
   106      * if the preview feature is removed.
       
   107      */
   123      */
   108     @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
   124     @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
   109     @SuppressWarnings("preview")
   125     @SuppressWarnings("preview")
   110     public default CaseKind getCaseKind() {
   126     public default CaseKind getCaseKind() {
   111         return CaseKind.STATEMENT;
   127         return CaseKind.STATEMENT;
   112     }
   128     }
   113 
   129 
   114     /**
   130     /**
       
   131      * {@preview Associated with switch expressions, a preview feature of
       
   132      *           the Java language.
       
   133      *
       
   134      *           This enum is associated with <i>switch expressions</i>, a preview
       
   135      *           feature of the Java language. Preview features
       
   136      *           may be removed in a future release, or upgraded to permanent
       
   137      *           features of the Java language.}
       
   138      *
   115      * The syntatic form of this case:
   139      * The syntatic form of this case:
   116      * <ul>
   140      * <ul>
   117      *     <li>STATEMENT: {@code case <expression>: <statements>}</li>
   141      *     <li>STATEMENT: {@code case <expression>: <statements>}</li>
   118      *     <li>RULE: {@code case <expression> -> <expression>/<statement>}</li>
   142      *     <li>RULE: {@code case <expression> -> <expression>/<statement>}</li>
   119      * </ul>
   143      * </ul>
   120      *
   144      *
   121      * @since 12
   145      * @since 12
   122      *
       
   123      * @preview This enum is used to model a rule case,
       
   124      * which is part of a preview feature and may be removed
       
   125      * if the preview feature is removed.
       
   126      */
   146      */
   127     @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
   147     @jdk.internal.PreviewFeature(feature=jdk.internal.PreviewFeature.Feature.SWITCH_EXPRESSIONS)
   128     @SuppressWarnings("preview")
   148     @SuppressWarnings("preview")
   129     public enum CaseKind {
   149     public enum CaseKind {
   130         /**
   150         /**