This repository has been archived by the owner on Nov 1, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c5ddcc2
commit bc593a8
Showing
4 changed files
with
88 additions
and
35 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
39 changes: 39 additions & 0 deletions
39
...src/main/java/com/whz/portfolio/infrastructure/persistence/PortfolioDataStateAdapter.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,39 @@ | ||
package com.whz.portfolio.infrastructure.persistence; | ||
|
||
import com.whz.portfolio.infrastructure.PortfolioData; | ||
|
||
import io.vlingo.common.serialization.JsonSerialization; | ||
import io.vlingo.symbio.Metadata; | ||
import io.vlingo.symbio.State.TextState; | ||
import io.vlingo.symbio.StateAdapter; | ||
|
||
public class PortfolioDataStateAdapter implements StateAdapter<PortfolioData, TextState> { | ||
|
||
@Override | ||
public int typeVersion() { | ||
return 1; | ||
} | ||
|
||
@Override | ||
public PortfolioData fromRawState(final TextState raw) { | ||
return JsonSerialization.deserialized(raw.data, raw.typed()); | ||
} | ||
|
||
@Override | ||
public TextState toRawState(String id, PortfolioData state, int stateVersion, Metadata metadata) { | ||
final String serialization = JsonSerialization.serialized(state); | ||
return new TextState(id, PortfolioData.class, typeVersion(), serialization, stateVersion, metadata); | ||
} | ||
|
||
@Override | ||
public TextState toRawState(PortfolioData state, int stateVersion, Metadata metadata) { | ||
final String serialization = JsonSerialization.serialized(state); | ||
return new TextState(state.id, PortfolioData.class, typeVersion(), serialization, stateVersion, metadata); | ||
} | ||
|
||
@Override | ||
public <ST> ST fromRawState(TextState raw, Class<ST> stateType) { | ||
return JsonSerialization.deserialized(raw.data, stateType); | ||
} | ||
|
||
} |
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