Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
lukehutch committed Nov 11, 2022
1 parent 44e455a commit 4915750
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 54 deletions.
103 changes: 51 additions & 52 deletions src/main/java/io/github/classgraph/ClassMemberInfo.java
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@
import nonapi.io.github.classgraph.utils.Assert;

/**
* Holds metadata about class members of a class encountered during a scan.
* All values are taken directly out of the classfile for the class.
* Holds metadata about class members of a class encountered during a scan. All values are taken directly out of the
* classfile for the class.
*/
public abstract class ClassMemberInfo extends ScanResultObject implements HasName {
/** Defining class name. */
Expand All @@ -55,8 +55,8 @@ public abstract class ClassMemberInfo extends ScanResultObject implements HasNam
protected String typeDescriptorStr;

/**
* The type signature (may have type parameter information included, if present and available).
* Method parameter types are unaligned.
* The type signature (may have type parameter information included, if present and available). Method parameter
* types are unaligned.
*/
protected String typeSignatureStr;

Expand Down Expand Up @@ -85,14 +85,15 @@ public abstract class ClassMemberInfo extends ScanResultObject implements HasNam
* {@link AnnotationInfo} for any annotations on the field.
*/
public ClassMemberInfo(final String definingClassName, final String memberName, final int modifiers,
final String typeDescriptorStr, final String typeSignatureStr, final AnnotationInfoList annotationInfo) {
super();
this.declaringClassName = definingClassName;
this.name = memberName;
this.modifiers = modifiers;
this.typeDescriptorStr = typeDescriptorStr;
this.typeSignatureStr = typeSignatureStr;
this.annotationInfo = annotationInfo == null || annotationInfo.isEmpty() ? null : annotationInfo;
final String typeDescriptorStr, final String typeSignatureStr,
final AnnotationInfoList annotationInfo) {
super();
this.declaringClassName = definingClassName;
this.name = memberName;
this.modifiers = modifiers;
this.typeDescriptorStr = typeDescriptorStr;
this.typeSignatureStr = typeSignatureStr;
this.annotationInfo = annotationInfo == null || annotationInfo.isEmpty() ? null : annotationInfo;
}

// -------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -149,7 +150,6 @@ public int getModifiers() {
*/
public abstract String getModifiersStr();


/**
* Returns true if this class member is public.
*
Expand Down Expand Up @@ -207,16 +207,16 @@ public boolean isSynthetic() {
// -------------------------------------------------------------------------------------------------------------

/**
* Returns the parsed type descriptor for the class member, which will not include type parameters.
* If you need generic type parameters, call {@link #getTypeSignature()} instead.
* Returns the parsed type descriptor for the class member, which will not include type parameters. If you need
* generic type parameters, call {@link #getTypeSignature()} instead.
*
* @return The parsed type descriptor string for the class member.
*/
public abstract HierarchicalTypeSignature getTypeDescriptor();

/**
* Returns the type descriptor string for the class member, which will not include type parameters.
* If you need generic type parameters, call {@link #getTypeSignatureStr()} instead.
* Returns the type descriptor string for the class member, which will not include type parameters. If you need
* generic type parameters, call {@link #getTypeSignatureStr()} instead.
*
* @return The type descriptor string for the class member.
*/
Expand All @@ -225,22 +225,22 @@ public String getTypeDescriptorStr() {
}

/**
* Returns the parsed type signature for the class member, possibly including type parameters.
* If this returns null, that no type signature information is available for this class member,
* call {@link #getTypeDescriptor()} instead.
* Returns the parsed type signature for the class member, possibly including type parameters. If this returns
* null, that no type signature information is available for this class member, call
* {@link #getTypeDescriptor()} instead.
*
* @return The parsed type signature for the class member, or null if not available.
* @throws IllegalArgumentException
* if the class member type signature cannot be parsed (this should only be thrown in
* the case of classfile corruption, or a compiler bug that causes an invalid type
* signature to be written to the classfile).
* if the class member type signature cannot be parsed (this should only be thrown in the case of
* classfile corruption, or a compiler bug that causes an invalid type signature to be written to
* the classfile).
*/
public abstract HierarchicalTypeSignature getTypeSignature();

/**
* Returns the type signature string for the class member, possibly including type parameters.
* If this returns null, indicating that no type signature information is available for this
* class member, call {@link #getTypeDescriptorStr()} instead.
* Returns the type signature string for the class member, possibly including type parameters. If this returns
* null, indicating that no type signature information is available for this class member, call
* {@link #getTypeDescriptorStr()} instead.
*
* @return The type signature string for the class member, or null if not available.
*/
Expand All @@ -249,22 +249,22 @@ public String getTypeSignatureStr() {
}

/**
* Returns the type signature for the class member, possibly including type parameters.
* If the type signature is null, indicating that no type signature information is available
* for this class member, returns the type descriptor instead.
* Returns the type signature for the class member, possibly including type parameters. If the type signature is
* null, indicating that no type signature information is available for this class member, returns the type
* descriptor instead.
*
* @return The parsed type signature for the class member, or if not available,
* the parsed type descriptor for the class member.
* @return The parsed type signature for the class member, or if not available, the parsed type descriptor for
* the class member.
*/
public abstract HierarchicalTypeSignature getTypeSignatureOrTypeDescriptor();

/**
* Returns the type signature string for the class member, possibly including type parameters.
* If the type signature string is null, indicating that no type signature information is available
* for this class member, returns the type descriptor string instead.
* Returns the type signature string for the class member, possibly including type parameters. If the type
* signature string is null, indicating that no type signature information is available for this class member,
* returns the type descriptor string instead.
*
* @return The type signature string for the class member, or if not available, the type descriptor
* string for the class member.
* @return The type signature string for the class member, or if not available, the type descriptor string for
* the class member.
*/
public String getTypeSignatureOrTypeDescriptorStr() {
if (typeSignatureStr != null) {
Expand All @@ -291,42 +291,41 @@ public AnnotationInfoList getAnnotationInfo() {
}

/**
* Get a the non-{@link Repeatable} annotation on this class member, or null if the class member does not
* have the annotation.
* (Use {@link #getAnnotationInfoRepeatable(Class)} for {@link Repeatable} annotations.)
* Get a the non-{@link Repeatable} annotation on this class member, or null if the class member does not have
* the annotation. (Use {@link #getAnnotationInfoRepeatable(Class)} for {@link Repeatable} annotations.)
*
* @param annotation
* The annotation.
* @return An {@link AnnotationInfo} object representing the annotation on this class member,
* or null if the class member does not have the annotation.
* @return An {@link AnnotationInfo} object representing the annotation on this class member, or null if the
* class member does not have the annotation.
*/
public AnnotationInfo getAnnotationInfo(final Class<? extends Annotation> annotation) {
Assert.isAnnotation(annotation);
return getAnnotationInfo(annotation.getName());
}

/**
* Get a the named non-{@link Repeatable} annotation on this class member, or null if the class member does
* not have the named annotation.
* (Use {@link #getAnnotationInfoRepeatable(String)} for {@link Repeatable} annotations.)
* Get a the named non-{@link Repeatable} annotation on this class member, or null if the class member does not
* have the named annotation. (Use {@link #getAnnotationInfoRepeatable(String)} for {@link Repeatable}
* annotations.)
*
* @param annotationName
* The annotation name.
* @return An {@link AnnotationInfo} object representing the named annotation on this class member,
* or null if the class member does not have the named annotation.
* @return An {@link AnnotationInfo} object representing the named annotation on this class member, or null if
* the class member does not have the named annotation.
*/
public AnnotationInfo getAnnotationInfo(final String annotationName) {
return getAnnotationInfo().get(annotationName);
}

/**
* Get a the {@link Repeatable} annotation on this class member, or the empty list if the class member does
* not have the annotation.
* Get a the {@link Repeatable} annotation on this class member, or the empty list if the class member does not
* have the annotation.
*
* @param annotation
* The annotation.
* @return An {@link AnnotationInfoList} of all instances of the annotation on this class member,
* or the empty list if the class member does not have the annotation.
* @return An {@link AnnotationInfoList} of all instances of the annotation on this class member, or the empty
* list if the class member does not have the annotation.
*/
public AnnotationInfoList getAnnotationInfoRepeatable(final Class<? extends Annotation> annotation) {
Assert.isAnnotation(annotation);
Expand All @@ -339,8 +338,8 @@ public AnnotationInfoList getAnnotationInfoRepeatable(final Class<? extends Anno
*
* @param annotationName
* The annotation name.
* @return An {@link AnnotationInfoList} of all instances of the named annotation on this class member,
* or the empty list if the class member does not have the named annotation.
* @return An {@link AnnotationInfoList} of all instances of the named annotation on this class member, or the
* empty list if the class member does not have the named annotation.
*/
public AnnotationInfoList getAnnotationInfoRepeatable(final String annotationName) {
return getAnnotationInfo().getRepeatable(annotationName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -435,7 +435,7 @@ public boolean addClasspathEntry(final Object pathElement, final ClassLoader cla
if (pathElementResolved.startsWith("//")) {
// Handle Windows UNC paths (#705)
try {
Path path = Paths.get(new URI(pathElementResolved));
final Path path = Paths.get(new URI(pathElementResolved));
if (addClasspathEntry(path, pathElementResolved, classLoader, scanSpec)) {
if (log != null) {
log.log("Found classpath element: " + path
Expand All @@ -444,7 +444,7 @@ public boolean addClasspathEntry(final Object pathElement, final ClassLoader cla
}
return true;
}
} catch (Exception e) {
} catch (final Exception e) {
// Fall through
}
}
Expand Down

0 comments on commit 4915750

Please sign in to comment.