Skip to content

Commit

Permalink
Merge pull request #604 from tkrautinger/latest
Browse files Browse the repository at this point in the history
Added missing getters for access flags/modifiers (ClassInfo, MethodInfo, FieldInfo)
  • Loading branch information
lukehutch committed Nov 26, 2021
2 parents 9e61b12 + 835d4d7 commit 7fb7d60
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/main/java/io/github/classgraph/ClassInfo.java
Expand Up @@ -1187,7 +1187,25 @@ public String getModifiersStr() {
* @return true if this class is a public class.
*/
public boolean isPublic() {
return (modifiers & Modifier.PUBLIC) != 0;
return Modifier.isPublic(modifiers);
}

/**
* Checks if the class is private.
*
* @return true if this class is a private class.
*/
public boolean isPrivate() {
return Modifier.isPrivate(modifiers);
}

/**
* Checks if the class is protected.
*
* @return true if this class is a protected class.
*/
public boolean isProtected() {
return Modifier.isProtected(modifiers);
}

/**
Expand All @@ -1196,7 +1214,7 @@ public boolean isPublic() {
* @return true if this class is an abstract class.
*/
public boolean isAbstract() {
return (modifiers & 0x400) != 0;
return Modifier.isAbstract(modifiers);
}

/**
Expand All @@ -1214,7 +1232,7 @@ public boolean isSynthetic() {
* @return true if this class is a final class.
*/
public boolean isFinal() {
return (modifiers & Modifier.FINAL) != 0;
return Modifier.isFinal(modifiers);
}

/**
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/io/github/classgraph/FieldInfo.java
Expand Up @@ -180,6 +180,24 @@ public String getModifiersStr() {
public boolean isPublic() {
return Modifier.isPublic(modifiers);
}

/**
* Returns true if this field is private.
*
* @return True if the field is private.
*/
public boolean isPrivate() {
return Modifier.isPrivate(modifiers);
}

/**
* Returns true if this field is protected.
*
* @return True if the field is protected.
*/
public boolean isProtected() {
return Modifier.isProtected(modifiers);
}

/**
* Returns true if this field is static.
Expand Down Expand Up @@ -207,6 +225,24 @@ public boolean isFinal() {
public boolean isTransient() {
return Modifier.isTransient(modifiers);
}

/**
* Returns true if this field is synthetic.
*
* @return True if the field is synthetic.
*/
public boolean isSynthetic() {
return (modifiers & 0x1000) != 0;
}

/**
* Returns true if this field is an enum constant.
*
* @return True if the field is an enum constant.
*/
public boolean isEnum() {
return (modifiers & 0x4000) != 0;
}

/**
* Returns the modifier bits for the field.
Expand Down
36 changes: 36 additions & 0 deletions src/main/java/io/github/classgraph/MethodInfo.java
Expand Up @@ -339,6 +339,24 @@ public boolean isConstructor() {
public boolean isPublic() {
return Modifier.isPublic(modifiers);
}

/**
* Returns true if this method is private.
*
* @return True if this method is private.
*/
public boolean isPrivate() {
return Modifier.isPrivate(modifiers);
}

/**
* Returns true if this method is protected.
*
* @return True if this method is protected.
*/
public boolean isProtected() {
return Modifier.isProtected(modifiers);
}

/**
* Returns true if this method is static.
Expand Down Expand Up @@ -402,6 +420,24 @@ public boolean isVarArgs() {
public boolean isNative() {
return Modifier.isNative(modifiers);
}

/**
* Returns true if this method is abstract.
*
* @return True if this method is abstract.
*/
public boolean isAbstract() {
return Modifier.isAbstract(modifiers);
}

/**
* Returns true if this method is strict.
*
* @return True if this method is strict.
*/
public boolean isStrict() {
return Modifier.isStrict(modifiers);
}

/**
* Returns true if this method has a body (i.e. has an implementation in the containing class).
Expand Down

0 comments on commit 7fb7d60

Please sign in to comment.