-
-
Notifications
You must be signed in to change notification settings - Fork 342
/
CtRecordPattern.java
84 lines (71 loc) · 2.32 KB
/
CtRecordPattern.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
* SPDX-License-Identifier: (MIT OR CECILL-C)
*
* Copyright (C) 2006-2023 INRIA and contributors
*
* Spoon is available either under the terms of the MIT License (see LICENSE-MIT.txt) or 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 spoon.reflect.path.CtRole;
import spoon.reflect.reference.CtTypeReference;
import spoon.support.UnsettableProperty;
import java.util.List;
// TODO (440) metamodel
/**
* This code element defines a record pattern, introduced in Java 21
* by <a href=https://openjdk.java.net/jeps/440>JEP 440</a>.
* <p>
* Example:
* <pre>
* Object obj = null;
* boolean longerThanTwo = false;
* record MyRecord(String value) {}
* // MyRecord(var string) is the record pattern
* if (obj instanceof MyRecord(var string)) {
* longerThanTwo = string.length() > 2;
* }
* </pre>
*/
public interface CtRecordPattern extends CtPattern, CtExpression<Void> {
/**
* {@return the type of the deconstructed record}
*/
@PropertyGetter(role = CtRole.TYPE_REF)
CtTypeReference<?> getRecordType();
/**
* Sets the type of the deconstructed record.
* @param recordType the record type.
*/
@PropertySetter(role = CtRole.TYPE_REF)
CtRecordPattern setRecordType(CtTypeReference<?> recordType);
/**
* {@return the inner patterns of this record pattern}
*/
@PropertyGetter(role = CtRole.PATTERN)
List<CtPattern> getPatternList();
/**
* Sets the inner patterns of this record pattern.
* @param patternList the list of inner patterns.
*/
@PropertySetter(role = CtRole.PATTERN)
CtRecordPattern setPatternList(List<CtPattern> patternList);
/**
* Adds an inner patterns to the list of inner patterns of this record.
* @param pattern the inner pattern.
*/
@PropertySetter(role = CtRole.PATTERN)
CtRecordPattern addPattern(CtPattern pattern);
@Override
CtRecordPattern clone();
@Override
@UnsettableProperty
List<CtTypeReference<?>> getTypeCasts();
@Override
@UnsettableProperty
<C extends CtExpression<Void>> C setTypeCasts(List<CtTypeReference<?>> types);
@Override
@UnsettableProperty
<C extends CtExpression<Void>> C addTypeCast(CtTypeReference<?> type);
}