Skip to content

Commit

Permalink
mashalling refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
hohwille committed Oct 5, 2024
1 parent d32f442 commit d2985c1
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -89,16 +89,19 @@ public V parse(String valueAsString) {

@Override
@SuppressWarnings("unchecked")
protected void readValue(StructuredReader reader) {
protected V readValue(StructuredReader reader, boolean apply) {

V id = (V) ((GenericId<?, ?, ?, ?>) this.value).readObject(reader);
set(id);
if (apply) {
set(id);
}
return id;
}

@Override
public void write(StructuredWriter writer) {
public void writeValue(StructuredWriter writer, V id) {

((GenericId<?, ?, ?, ?>) this.value).write(writer);
((GenericId<?, ?, ?, ?>) id).write(writer);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -196,18 +196,20 @@ protected Supplier<? extends Link<E>> createReadOnlyExpression() {
}

@Override
protected void readValue(StructuredReader reader) {
protected Link<E> readValue(StructuredReader reader, boolean apply) {

Id<E> id = IdMarshalling.get().readObject(reader, this.entityClass);
IdLink<E> link = IdLink.of(id, this.resolver);
setValue(link);
if (apply) {
setValue(link);
}
return link;
}

@Override
public void write(StructuredWriter writer) {
public void writeValue(StructuredWriter writer, Link<E> link) {

Id<E> id = null;
Link<E> link = getValue();
if (link != null) {
id = link.getId();
}
Expand Down

0 comments on commit d2985c1

Please sign in to comment.