1 /* |
|
2 * Copyright (c) 2003, 2018, Oracle and/or its affiliates. All rights reserved. |
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
|
4 * |
|
5 * This code is free software; you can redistribute it and/or modify it |
|
6 * under the terms of the GNU General Public License version 2 only, as |
|
7 * published by the Free Software Foundation. Oracle designates this |
|
8 * particular file as subject to the "Classpath" exception as provided |
|
9 * by Oracle in the LICENSE file that accompanied this code. |
|
10 * |
|
11 * This code is distributed in the hope that it will be useful, but WITHOUT |
|
12 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
|
13 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
|
14 * version 2 for more details (a copy is included in the LICENSE file that |
|
15 * accompanied this code). |
|
16 * |
|
17 * You should have received a copy of the GNU General Public License version |
|
18 * 2 along with this work; if not, write to the Free Software Foundation, |
|
19 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
|
20 * |
|
21 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
|
22 * or visit www.oracle.com if you need additional information or have any |
|
23 * questions. |
|
24 */ |
|
25 |
|
26 package com.sun.tools.javadoc.main; |
|
27 |
|
28 import com.sun.javadoc.*; |
|
29 import com.sun.tools.javac.code.Attribute; |
|
30 import com.sun.tools.javac.code.Attribute.TypeCompound; |
|
31 import com.sun.tools.javac.util.List; |
|
32 |
|
33 /** |
|
34 * Implementation of <code>AnnotatedType</code>, which |
|
35 * represents an annotated type. |
|
36 * |
|
37 * @author Mahmood Ali |
|
38 * @since 1.8 |
|
39 */ |
|
40 @Deprecated(since="9", forRemoval=true) |
|
41 @SuppressWarnings("removal") |
|
42 public class AnnotatedTypeImpl |
|
43 extends AbstractTypeImpl implements AnnotatedType { |
|
44 |
|
45 AnnotatedTypeImpl(DocEnv env, com.sun.tools.javac.code.Type type) { |
|
46 super(env, type); |
|
47 } |
|
48 |
|
49 /** |
|
50 * Get the annotations of this program element. |
|
51 * Return an empty array if there are none. |
|
52 */ |
|
53 @Override |
|
54 public AnnotationDesc[] annotations() { |
|
55 List<? extends TypeCompound> tas = type.getAnnotationMirrors(); |
|
56 if (tas == null || |
|
57 tas.isEmpty()) { |
|
58 return new AnnotationDesc[0]; |
|
59 } |
|
60 AnnotationDesc res[] = new AnnotationDesc[tas.length()]; |
|
61 int i = 0; |
|
62 for (Attribute.Compound a : tas) { |
|
63 res[i++] = new AnnotationDescImpl(env, a); |
|
64 } |
|
65 return res; |
|
66 } |
|
67 |
|
68 @Override |
|
69 public com.sun.javadoc.Type underlyingType() { |
|
70 return TypeMaker.getType(env, type, true, false); |
|
71 } |
|
72 |
|
73 @Override |
|
74 public AnnotatedType asAnnotatedType() { |
|
75 return this; |
|
76 } |
|
77 |
|
78 @Override |
|
79 public String toString() { |
|
80 return typeName(); |
|
81 } |
|
82 |
|
83 @Override |
|
84 public String typeName() { |
|
85 return this.underlyingType().typeName(); |
|
86 } |
|
87 |
|
88 @Override |
|
89 public String qualifiedTypeName() { |
|
90 return this.underlyingType().qualifiedTypeName(); |
|
91 } |
|
92 |
|
93 @Override |
|
94 public String simpleTypeName() { |
|
95 return this.underlyingType().simpleTypeName(); |
|
96 } |
|
97 |
|
98 @Override |
|
99 public String dimension() { |
|
100 return this.underlyingType().dimension(); |
|
101 } |
|
102 |
|
103 @Override |
|
104 public boolean isPrimitive() { |
|
105 return this.underlyingType().isPrimitive(); |
|
106 } |
|
107 |
|
108 @Override |
|
109 public ClassDoc asClassDoc() { |
|
110 return this.underlyingType().asClassDoc(); |
|
111 } |
|
112 |
|
113 @Override |
|
114 public TypeVariable asTypeVariable() { |
|
115 return this.underlyingType().asTypeVariable(); |
|
116 } |
|
117 |
|
118 @Override |
|
119 public WildcardType asWildcardType() { |
|
120 return this.underlyingType().asWildcardType(); |
|
121 } |
|
122 |
|
123 @Override |
|
124 public ParameterizedType asParameterizedType() { |
|
125 return this.underlyingType().asParameterizedType(); |
|
126 } |
|
127 } |
|