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