Skip to content

Commit 0538be3

Browse files
committed
Expose getTypeDescriptorStr() and getTypeSignatureStr() (#380)
1 parent 355b163 commit 0538be3

3 files changed

Lines changed: 99 additions & 10 deletions

File tree

src/main/java/io/github/classgraph/ClassInfo.java

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2455,9 +2455,10 @@ ClassInfoList getClassesWithFieldAnnotationDirectOnly() {
24552455
// -------------------------------------------------------------------------------------------------------------
24562456

24572457
/**
2458-
* Get the type signature of the class.
2458+
* Get the parsed type signature for the class.
24592459
*
2460-
* @return The class type signature, if available, otherwise returns null.
2460+
* @return The parsed type signature for the class, including any generic type parameters, or null if not
2461+
* available (probably indicating the class is not generic).
24612462
*/
24622463
public ClassTypeSignature getTypeSignature() {
24632464
if (typeSignatureStr == null) {
@@ -2474,6 +2475,16 @@ public ClassTypeSignature getTypeSignature() {
24742475
return typeSignature;
24752476
}
24762477

2478+
/**
2479+
* Get the type signature string for the class.
2480+
*
2481+
* @return The type signature string for the class, including any generic type parameters, or null if not
2482+
* available (probably indicating the class is not generic).
2483+
*/
2484+
public String getTypeSignatureStr() {
2485+
return typeSignatureStr;
2486+
}
2487+
24772488
// -------------------------------------------------------------------------------------------------------------
24782489

24792490
/**

src/main/java/io/github/classgraph/FieldInfo.java

Lines changed: 44 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -197,9 +197,10 @@ public int getModifiers() {
197197
}
198198

199199
/**
200-
* Returns the parsed type descriptor for the field, if available.
200+
* Returns the parsed type descriptor for the field, which will not include type parameters. If you need generic
201+
* type parameters, call {@link #getTypeSignature()} instead.
201202
*
202-
* @return The parsed type descriptor for the field, if available, else returns null.
203+
* @return The parsed type descriptor string for the field.
203204
*/
204205
public TypeSignature getTypeDescriptor() {
205206
if (typeDescriptorStr == null) {
@@ -217,9 +218,21 @@ public TypeSignature getTypeDescriptor() {
217218
}
218219

219220
/**
220-
* Returns the parsed type signature for the field, if available.
221+
* Returns the type descriptor string for the field, which will not include type parameters. If you need generic
222+
* type parameters, call {@link #getTypeSignatureStr()} instead.
221223
*
222-
* @return The parsed type signature for the field, if available, else returns null.
224+
* @return The type descriptor string for the field.
225+
*/
226+
public String getTypeDescriptorStr() {
227+
return typeDescriptorStr;
228+
}
229+
230+
/**
231+
* Returns the parsed type signature for the field, possibly including type parameters. If this returns null,
232+
* indicating that no type signature information is available for this field, call {@link #getTypeDescriptor()}
233+
* instead.
234+
*
235+
* @return The parsed type signature for the field, or null if not available.
223236
*/
224237
public TypeSignature getTypeSignature() {
225238
if (typeSignatureStr == null) {
@@ -236,6 +249,17 @@ public TypeSignature getTypeSignature() {
236249
return typeSignature;
237250
}
238251

252+
/**
253+
* Returns the type signature string for the field, possibly including type parameters. If this returns null,
254+
* indicating that no type signature information is available for this field, call
255+
* {@link #getTypeDescriptorStr()} instead.
256+
*
257+
* @return The type signature string for the field, or null if not available.
258+
*/
259+
public String getTypeSignatureStr() {
260+
return typeSignatureStr;
261+
}
262+
239263
/**
240264
* Returns the type signature for the field, possibly including type parameters. If the type signature is null,
241265
* indicating that no type signature information is available for this field, returns the type descriptor
@@ -253,6 +277,22 @@ public TypeSignature getTypeSignatureOrTypeDescriptor() {
253277
}
254278
}
255279

280+
/**
281+
* Returns the type signature string for the field, possibly including type parameters. If the type signature
282+
* string is null, indicating that no type signature information is available for this field, returns the type
283+
* descriptor string instead.
284+
*
285+
* @return The type signature string for the field, or if not available, the type descriptor string for the
286+
* method.
287+
*/
288+
public String getTypeSignatureOrTypeDescriptorStr() {
289+
if (typeSignatureStr != null) {
290+
return typeSignatureStr;
291+
} else {
292+
return typeDescriptorStr;
293+
}
294+
}
295+
256296
/**
257297
* Returns the constant initializer value of a constant final field. Requires
258298
* {@link ClassGraph#enableStaticFinalFieldConstantInitializerValues()} to have been called.

src/main/java/io/github/classgraph/MethodInfo.java

Lines changed: 42 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public ClassInfo getClassInfo() {
192192

193193
/**
194194
* Returns the parsed type descriptor for the method, which will not include type parameters. If you need
195-
* generic type parameters, call getTypeSignature() instead.
195+
* generic type parameters, call {@link #getTypeSignature()} instead.
196196
*
197197
* @return The parsed type descriptor for the method.
198198
*/
@@ -208,9 +208,20 @@ public MethodTypeSignature getTypeDescriptor() {
208208
return typeDescriptor;
209209
}
210210

211+
/**
212+
* Returns the type descriptor string for the method, which will not include type parameters. If you need
213+
* generic type parameters, call {@link #getTypeSignatureStr()} instead.
214+
*
215+
* @return The type descriptor string for the method.
216+
*/
217+
public String getTypeDescriptorStr() {
218+
return typeDescriptorStr;
219+
}
220+
211221
/**
212222
* Returns the parsed type signature for the method, possibly including type parameters. If this returns null,
213-
* indicating that no type signature information is available for this method, call getTypeDescriptor() instead.
223+
* indicating that no type signature information is available for this method, call {@link #getTypeDescriptor()}
224+
* instead.
214225
*
215226
* @return The parsed type signature for the method, or null if not available.
216227
*/
@@ -227,8 +238,19 @@ public MethodTypeSignature getTypeSignature() {
227238
}
228239

229240
/**
230-
* Returns the parsed type signature for the method, possibly including type parameters. If the parsed type
231-
* signature is null, indicating that no type signature information is available for this method, returns the
241+
* Returns the type signature string for the method, possibly including type parameters. If this returns null,
242+
* indicating that no type signature information is available for this method, call
243+
* {@link #getTypeDescriptorStr()} instead.
244+
*
245+
* @return The type signature string for the method, or null if not available.
246+
*/
247+
public String getTypeSignatureStr() {
248+
return typeSignatureStr;
249+
}
250+
251+
/**
252+
* Returns the parsed type signature for the method, possibly including type parameters. If the type signature
253+
* string is null, indicating that no type signature information is available for this method, returns the
232254
* parsed type descriptor instead.
233255
*
234256
* @return The parsed type signature for the method, or if not available, the parsed type descriptor for the
@@ -243,6 +265,22 @@ public MethodTypeSignature getTypeSignatureOrTypeDescriptor() {
243265
}
244266
}
245267

268+
/**
269+
* Returns the type signature string for the method, possibly including type parameters. If the type signature
270+
* string is null, indicating that no type signature information is available for this method, returns the type
271+
* descriptor string instead.
272+
*
273+
* @return The type signature string for the method, or if not available, the type descriptor string for the
274+
* method.
275+
*/
276+
public String getTypeSignatureOrTypeDescriptorStr() {
277+
if (typeSignatureStr != null) {
278+
return typeSignatureStr;
279+
} else {
280+
return typeDescriptorStr;
281+
}
282+
}
283+
246284
// -------------------------------------------------------------------------------------------------------------
247285

248286
/**

0 commit comments

Comments
 (0)