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.reference;
19:
20: import java.lang.annotation.Annotation;
21: import java.util.ArrayList;
22: import java.util.List;
23:
24: import spoon.reflect.reference.CtTypeParameterReference;
25: import spoon.reflect.reference.CtTypeReference;
26: import spoon.reflect.visitor.CtVisitor;
27:
28: public class CtTypeParameterReferenceImpl extends
29: CtTypeReferenceImpl<Object> implements CtTypeParameterReference {
30: private static final long serialVersionUID = 1L;
31:
32: List<CtTypeReference<?>> bounds = new ArrayList<CtTypeReference<?>>();
33:
34: boolean upper = true;
35:
36: public CtTypeParameterReferenceImpl() {
37: super ();
38: }
39:
40: @Override
41: public void accept(CtVisitor visitor) {
42: visitor.visitCtTypeParameterReference(this );
43: }
44:
45: @Override
46: public <A extends Annotation> A getAnnotation(
47: Class<A> annotationType) {
48: return null;
49: }
50:
51: public List<CtTypeReference<?>> getBounds() {
52: return bounds;
53: }
54:
55: public boolean isUpper() {
56: return upper;
57: }
58:
59: public void setBounds(List<CtTypeReference<?>> bounds) {
60: this .bounds = bounds;
61: }
62:
63: public void setUpper(boolean upper) {
64: this .upper = upper;
65: }
66:
67: @Override
68: public boolean isAssignableFrom(CtTypeReference<?> type) {
69: return false;
70: }
71:
72: @Override
73: public boolean isSubtypeOf(CtTypeReference<?> type) {
74: return false;
75: }
76:
77: @Override
78: public boolean isPrimitive() {
79: return false;
80: }
81:
82: @Override
83: public void setSimpleName(String simplename) {
84: this .simplename = simplename;
85: }
86:
87: @Override
88: @SuppressWarnings("unchecked")
89: public Class<Object> getActualClass() {
90: if (isUpper()) {
91: if (getBounds().isEmpty()) {
92: return Object.class;
93: }
94: return (Class) getBounds().get(0).getActualClass();
95: }
96: return null;
97: }
98:
99: }
|