Skip to content

Commit a030a3e

Browse files
committed
Revert "feat(#419): filter out static methods from records"
This reverts commit 1cff66f.
1 parent 1cff66f commit a030a3e

2 files changed

Lines changed: 0 additions & 41 deletions

File tree

johnzon-jsonb/src/test/java/org/apache/johnzon/jsonb/JsonbRecordTest.java

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@
2424
import org.junit.Test;
2525

2626
import jakarta.json.bind.annotation.JsonbProperty;
27-
28-
import java.time.LocalDate;
2927
import java.util.Objects;
3028

3129
import static org.junit.Assert.assertEquals;
@@ -86,41 +84,4 @@ public int hashCode() {
8684
return Objects.hash(age, name);
8785
}
8886
}
89-
90-
@Test
91-
public void roundTripWithActualJavaRecord() {
92-
final var ref = new Person("john", LocalDate.of(1904, 12, 25));
93-
final String expectedJson = "{\"age\":121,\"birthday\":\"1904-12-25\",\"name\":\"john\"}";
94-
assertEquals(expectedJson, jsonb.toJson(ref));
95-
assertEquals(ref, jsonb.fromJson(expectedJson, Person.class));
96-
}
97-
98-
public record Person (String name, LocalDate birthday) {
99-
public int age() {
100-
return LocalDate.now().getYear() - birthday.getYear();
101-
}
102-
103-
public static Builder builder() {
104-
return new Builder();
105-
}
106-
107-
public static class Builder {
108-
private String name;
109-
private LocalDate birthday;
110-
111-
public Builder name(String name) {
112-
this.name = name;
113-
return this;
114-
}
115-
116-
public Builder birthday(LocalDate birthday) {
117-
this.birthday = birthday;
118-
return this;
119-
}
120-
121-
public Person build() {
122-
return new Person(name, birthday);
123-
}
124-
}
125-
}
12687
}

johnzon-mapper/src/main/java/org/apache/johnzon/mapper/access/MethodAccessMode.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@
2626
import java.beans.PropertyDescriptor;
2727
import java.lang.annotation.Annotation;
2828
import java.lang.reflect.Method;
29-
import java.lang.reflect.Modifier;
3029
import java.lang.reflect.Type;
3130
import java.util.Collection;
3231
import java.util.HashMap;
@@ -55,7 +54,6 @@ public Map<String, Reader> doFindReaders(final Class<?> clazz) {
5554
readers.putAll(Stream.of(clazz.getMethods())
5655
.filter(it -> it.getDeclaringClass() != Object.class && it.getParameterCount() == 0)
5756
.filter(it -> !"toString".equals(it.getName()) && !"hashCode".equals(it.getName()))
58-
.filter(it -> !Modifier.isStatic(it.getModifiers()))
5957
.filter(it -> !isIgnored(it.getName()) && Meta.getAnnotation(it, JohnzonAny.class) == null)
6058
.collect(toMap(m -> extractKey(m.getName(), m, null), it -> new MethodReader(it, it.getGenericReturnType()))));
6159
} else {

0 commit comments

Comments
 (0)