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.declaration;
19:
20: import java.util.ArrayList;
21: import java.util.List;
22: import java.util.Set;
23: import java.util.TreeSet;
24: import java.util.Vector;
25:
26: import spoon.reflect.code.CtBlock;
27: import spoon.reflect.declaration.CtExecutable;
28: import spoon.reflect.declaration.CtParameter;
29: import spoon.reflect.reference.CtExecutableReference;
30: import spoon.reflect.reference.CtTypeReference;
31:
32: /**
33: * The implementation for {@link spoon.reflect.declaration.CtExecutable}.
34: *
35: * @author Renaud Pawlak
36: */
37: public abstract class CtExecutableImpl<R> extends CtNamedElementImpl
38: implements CtExecutable<R> {
39:
40: CtBlock<?> body;
41:
42: List<CtTypeReference<?>> formalTypeParameters = new ArrayList<CtTypeReference<?>>();
43:
44: List<CtParameter<?>> parameters = new Vector<CtParameter<?>>();
45:
46: Set<CtTypeReference<? extends Throwable>> thrownTypes = new TreeSet<CtTypeReference<? extends Throwable>>();
47:
48: public CtExecutableImpl() {
49: super ();
50: }
51:
52: @SuppressWarnings("unchecked")
53: public <B extends R> CtBlock<B> getBody() {
54: return (CtBlock<B>) body;
55: }
56:
57: public List<CtTypeReference<?>> getFormalTypeParameters() {
58: return formalTypeParameters;
59: }
60:
61: public List<CtParameter<?>> getParameters() {
62: return parameters;
63: }
64:
65: public Set<CtTypeReference<? extends Throwable>> getThrownTypes() {
66: return thrownTypes;
67: }
68:
69: @SuppressWarnings("unchecked")
70: public <B extends R> void setBody(CtBlock<B> body) {
71: this .body = body;
72: }
73:
74: public void setFormalTypeParameters(
75: List<CtTypeReference<?>> formalTypeParameters) {
76: this .formalTypeParameters = formalTypeParameters;
77: }
78:
79: public void setParameters(List<CtParameter<?>> parameters) {
80: this .parameters = parameters;
81: }
82:
83: public void setThrownTypes(
84: Set<CtTypeReference<? extends Throwable>> thrownTypes) {
85: this .thrownTypes = thrownTypes;
86: }
87:
88: @Override
89: public CtExecutableReference<R> getReference() {
90: return getFactory().Executable().createReference(this);
91: }
92:
93: }
|