-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: allow tag containing repeated elements to be mapped to multiple …
…collection types A tag containing multiple repeated different tags can now be mapped to multiple different collection types. <a> <b/> <c/> <b/> <c/> </a> can be mapped to two fields @tag(path = "/a", items = "b") List<B> bs; @tag(path = "/a", items = "c") List<B> cs;
- Loading branch information
1 parent
2bc0333
commit 8c8eee9
Showing
8 changed files
with
789 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
xjx-serdes/src/main/java/io/jonasg/xjx/serdes/deserialize/LazySupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
package io.jonasg.xjx.serdes.deserialize; | ||
|
||
import java.util.function.Supplier; | ||
|
||
public class LazySupplier<T> implements Supplier<T> { | ||
private T instance; | ||
private Supplier<T> initializer; | ||
|
||
public LazySupplier(Supplier<T> initializer) { | ||
this.initializer = initializer; | ||
} | ||
|
||
@Override | ||
public T get() { | ||
if (instance == null) { | ||
instance = initializer.get(); | ||
} | ||
return instance; | ||
} | ||
|
||
public void reset(Supplier<T> supplier) { | ||
this.instance = null; | ||
this.initializer = supplier; | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
xjx-serdes/src/main/java/io/jonasg/xjx/serdes/deserialize/PathWriterIndex.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.jonasg.xjx.serdes.deserialize; | ||
|
||
import io.jonasg.xjx.serdes.Path; | ||
|
||
import java.util.ArrayList; | ||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
public class PathWriterIndex { | ||
|
||
private final Map<Path, List<PathWriter>> index = new HashMap<>(); | ||
|
||
public void put(Path path, PathWriter pathWriter) { | ||
index.compute(path, (p, w) -> { | ||
if (w == null) { | ||
List<PathWriter> pathWriters = new ArrayList<>(); | ||
pathWriters.add(pathWriter); | ||
return pathWriters; | ||
} | ||
w.add(pathWriter); | ||
return w; | ||
}); | ||
} | ||
|
||
public void putAll(PathWriterIndex pathWriterIndex) { | ||
index.putAll(pathWriterIndex.index); | ||
} | ||
|
||
public List<PathWriter> get(Path path) { | ||
return index.get(path); | ||
} | ||
} |
Oops, something went wrong.