Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expose declaring class for FieldRef #490

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions core/src/main/java/org/kohsuke/stapler/lang/FieldRef.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,13 @@ public boolean keep(FieldRef m) {
*/
public abstract String getQualifiedName();

/**
* Returns the {@code Class} object representing the class or interface
* that declares the executable represented by this object.
* @see java.lang.reflect.Member#getDeclaringClass()
*/
public abstract Class<?> getDeclaringClass();

/**
* Gets the signature for this for use in lists
*
Expand Down Expand Up @@ -107,6 +114,11 @@ public String getSignature() {
return String.join(" ", prefix, f.getDeclaringClass().getName(), getName());
}

@Override
public Class<?> getDeclaringClass() {
return f.getDeclaringClass();
}

@Override
public String getQualifiedName() {
return f.getDeclaringClass().getName()+"."+getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,11 @@ protected FieldRef getBase() {
return f;
}

@Override
public Class<?> getDeclaringClass() {
return f.getDeclaringClass();
}

@Override
public String getSignature() {
return f.getQualifiedName(); // doesn't really matter
Expand Down