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

[MNG-8024] Make WrapperProperties and WrapperList serizalizable. #1388

Closed
wants to merge 2 commits into from
Closed
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
17 changes: 11 additions & 6 deletions src/mdo/java/WrapperList.java
Original file line number Diff line number Diff line change
Expand Up @@ -27,16 +27,21 @@
import java.util.function.Supplier;

class WrapperList<T, U> extends AbstractList<T> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the point is the WrapperList itself does not implement Serializable ?

private final Supplier<List<U>> getter;
private final Consumer<List<U>> setter;
private final Function<U, T> mapper;
private final Function<T, U> revMapper;
public interface SerializableConsumer<T> extends java.util.function.Consumer<T>, java.io.Serializable {}
public interface SerializableFunction<U, T> extends java.util.function.Function<U, T>, java.io.Serializable {}
public interface SerializableSupplier<T> extends java.util.function.Supplier<T>, java.io.Serializable {}

WrapperList(List<U> list, Function<U, T> mapper, Function<T, U> revMapper) {

private final SerializableSupplier<List<U>> getter;
private final SerializableConsumer<List<U>> setter;
private final SerializableFunction<U, T> mapper;
private final SerializableFunction<T, U> revMapper;

WrapperList(List<U> list, SerializableFunction<U, T> mapper, SerializableFunction<T, U> revMapper) {
this(() -> list, null, mapper, revMapper);
}

WrapperList(Supplier<List<U>> getter, Consumer<List<U>> setter, Function<U, T> mapper, Function<T, U> revMapper) {
WrapperList(SerializableSupplier<List<U>> getter, SerializableConsumer<List<U>> setter, SerializableFunction<U, T> mapper, SerializableFunction<T, U> revMapper) {
this.getter = getter;
this.setter = setter;
this.mapper = mapper;
Expand Down
9 changes: 6 additions & 3 deletions src/mdo/java/WrapperProperties.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,13 @@

class WrapperProperties extends Properties {

final Supplier<Map<String, String>> getter;
final Consumer<Properties> setter;
public interface SerializableConsumer<T> extends java.util.function.Consumer<T>, java.io.Serializable {}
public interface SerializableSupplier<T> extends java.util.function.Supplier<T>, java.io.Serializable {}

WrapperProperties(Supplier<Map<String, String>> getter, Consumer<Properties> setter) {
final SerializableSupplier<Map<String, String>> getter;
final SerializableConsumer<Properties> setter;

WrapperProperties(SerializableSupplier<Map<String, String>> getter, SerializableConsumer<Properties> setter) {
this.getter = getter;
this.setter = setter;
}
Expand Down