Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import java.beans.IntrospectionException;
import java.beans.PropertyDescriptor;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Enumeration;
Expand Down Expand Up @@ -71,11 +72,13 @@ public static Collection<? extends PropertyDescriptor> determineBasicProperties(
setter = true;
nameIndex = 3;
}
else if (methodName.startsWith("get") && method.getParameterCount() == 0 && method.getReturnType() != void.class) {
else if (methodName.startsWith("get") && method.getParameterCount() == 0 &&
method.getReturnType() != void.class && !Modifier.isStatic(method.getModifiers())) {
setter = false;
nameIndex = 3;
}
else if (methodName.startsWith("is") && method.getParameterCount() == 0 && method.getReturnType() == boolean.class) {
else if (methodName.startsWith("is") && method.getParameterCount() == 0 &&
method.getReturnType() == boolean.class && !Modifier.isStatic(method.getModifiers())) {
setter = false;
nameIndex = 2;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,13 @@ void classWithOnlyGetter() {
assertReadAndWriteMethodsForClassAndId(pdMap, Number.class, null);
}

@Test
void classWithStaticGetters() {
var pdMap = resolver.resolve(ClassWithStaticGetters.class);

assertThat(pdMap).containsOnlyKeys("class");
}

@Test
void classWithOnlySetter() {
var pdMap = resolver.resolve(ClassWithOnlySetter.class);
Expand Down Expand Up @@ -134,6 +141,17 @@ public Number getId() {
}
}

static class ClassWithStaticGetters {

public static Long getId() {
return 42L;
}

public static boolean isActive() {
return true;
}
}

static class ClassWithOnlySetter {

public void setId(Long id) {
Expand Down