01: /*
02: * Spoon - http://spoon.gforge.inria.fr/
03: * Copyright (C) 2006 INRIA Futurs <renaud.pawlak@inria.fr>
04: *
05: * This software is governed by the CeCILL-C License under French law and
06: * abiding by the rules of distribution of free software. You can use, modify
07: * and/or redistribute the software under the terms of the CeCILL-C license as
08: * circulated by CEA, CNRS and INRIA at http://www.cecill.info.
09: *
10: * This program is distributed in the hope that it will be useful, but WITHOUT
11: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12: * FITNESS FOR A PARTICULAR PURPOSE. See the CeCILL-C License for more details.
13: *
14: * The fact that you are presently reading this means that you have had
15: * knowledge of the CeCILL-C license and that you accept its terms.
16: */
17:
18: package spoon.support.reflect.code;
19:
20: import spoon.reflect.code.CtExpression;
21: import spoon.reflect.code.CtStatement;
22: import spoon.reflect.code.CtStatementList;
23: import spoon.reflect.code.CtUnaryOperator;
24: import spoon.reflect.code.UnaryOperatorKind;
25: import spoon.reflect.declaration.CtElement;
26: import spoon.reflect.visitor.CtVisitor;
27:
28: public class CtUnaryOperatorImpl<T> extends CtExpressionImpl<T>
29: implements CtUnaryOperator<T> {
30: private static final long serialVersionUID = 1L;
31:
32: UnaryOperatorKind kind;
33:
34: String label;
35:
36: CtExpression<T> operand;
37:
38: public void accept(CtVisitor visitor) {
39: visitor.visitCtUnaryOperator(this );
40: }
41:
42: public CtExpression<T> getOperand() {
43: return operand;
44: }
45:
46: public UnaryOperatorKind getKind() {
47: return kind;
48: }
49:
50: public String getLabel() {
51: return label;
52: }
53:
54: public void insertAfter(CtStatement statement) {
55: CtStatementImpl.insertAfter(this , statement);
56: }
57:
58: public void insertBefore(CtStatement statement) {
59: CtStatementImpl.insertBefore(this , statement);
60: }
61:
62: public void insertAfter(CtStatementList<?> statements) {
63: CtStatementImpl.insertAfter(this , statements);
64: }
65:
66: public void insertBefore(CtStatementList<?> statements) {
67: CtStatementImpl.insertBefore(this , statements);
68: }
69:
70: public void replace(CtElement element) {
71: if (element instanceof CtStatementList) {
72: CtStatementImpl.replace(this , (CtStatementList<?>) element);
73: } else {
74: super .replace(element);
75: }
76: }
77:
78: public void setOperand(CtExpression<T> expression) {
79: this .operand = expression;
80:
81: }
82:
83: public void setKind(UnaryOperatorKind kind) {
84: this .kind = kind;
85: }
86:
87: public void setLabel(String label) {
88: this.label = label;
89: }
90:
91: }
|