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 package com.helger.jcodemodel;
42
43 import java.util.Collections;
44 import java.util.Iterator;
45 import java.util.List;
46
47 import javax.annotation.Nonnull;
48 import javax.annotation.Nullable;
49
50
51
52
53
54
55
56
57 public class JDirectClass extends AbstractJClassContainer <JDirectClass>
58 {
59
60 private final String m_sFullName;
61
62 @Deprecated
63 protected JDirectClass (@Nonnull final JCodeModel aOwner, @Nonnull final String sFullName)
64 {
65 this (aOwner, null, EClassType.CLASS, sFullName);
66 }
67
68 @Nonnull
69 private static String _getName (@Nonnull final String sFullName)
70 {
71 final int nLast = sFullName.lastIndexOf ('.');
72 if (nLast < 0)
73 return sFullName;
74 return sFullName.substring (nLast + 1);
75 }
76
77 protected JDirectClass (@Nonnull final JCodeModel aOwner,
78 @Nullable final IJClassContainer <?> aOuter,
79 @Nonnull final EClassType eClassType,
80 @Nonnull final String sFullName)
81 {
82 super (aOwner, aOuter, eClassType, _getName (sFullName));
83 m_sFullName = sFullName;
84 }
85
86 @Override
87 @Nonnull
88 public String name ()
89 {
90 return super.name ();
91 }
92
93
94
95
96 @Override
97 @Nonnull
98 public String fullName ()
99 {
100 if (getOuter () instanceof AbstractJClassContainer <?>)
101 return ((AbstractJClassContainer <?>) getOuter ()).fullName () + '.' + m_sFullName;
102
103
104 return m_sFullName;
105 }
106
107 @Override
108 @Nonnull
109 public JPackage _package ()
110 {
111 final IJClassContainer <?> aOuter = getOuter ();
112 if (aOuter instanceof AbstractJClassContainer <?>)
113 return ((AbstractJClassContainer <?>) aOuter)._package ();
114 if (aOuter instanceof JPackage)
115 return (JPackage) aOuter;
116
117
118 final String sFullName = fullName ();
119 final int i = sFullName.lastIndexOf ('.');
120 if (i >= 0)
121 return owner ()._package (sFullName.substring (0, i));
122 return owner ().rootPackage ();
123 }
124
125 @Override
126 @Nonnull
127 public AbstractJClass _extends ()
128 {
129 return owner ().ref (Object.class);
130 }
131
132 @Override
133 @Nonnull
134 public Iterator <AbstractJClass> _implements ()
135 {
136 return Collections.<AbstractJClass> emptyList ().iterator ();
137 }
138
139 @Override
140 public boolean isAbstract ()
141 {
142 return false;
143 }
144
145 @Override
146 @Nonnull
147 protected AbstractJClass substituteParams (final JTypeVar [] variables,
148 final List <? extends AbstractJClass> bindings)
149 {
150 return this;
151 }
152
153 @Override
154 @Nonnull
155 protected JDirectClass createInnerClass (final int nMods, final EClassType eClassType, final String sName)
156 {
157 return new JDirectClass (owner (), this, eClassType, sName);
158 }
159 }