Skip to content

Commit

Permalink
iluwatar#987 for visitor, value-object, unitofwork, typeobjectpattern…
Browse files Browse the repository at this point in the history
…, tolerantreader, twin, tranpoline
  • Loading branch information
Anurag870 committed Oct 26, 2019
1 parent 68cf31f commit c836d93
Showing 1 changed file with 17 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,13 @@ private RainbowFishSerializer() {
* Write V1 RainbowFish to file
*/
public static void writeV1(RainbowFish rainbowFish, String filename) throws IOException {
var map = new HashMap<String, String>();
map.put("name", rainbowFish.getName());
map.put("age", String.format("%d", rainbowFish.getAge()));
map.put("lengthMeters", String.format("%d", rainbowFish.getLengthMeters()));
map.put("weightTons", String.format("%d", rainbowFish.getWeightTons()));
var map = Map.of(
"name", rainbowFish.getName(),
"age", String.format("%d", rainbowFish.getAge()),
"lengthMeters", String.format("%d", rainbowFish.getLengthMeters()),
"weightTons", String.format("%d", rainbowFish.getWeightTons())
);

try (var fileOut = new FileOutputStream(filename);
var objOut = new ObjectOutputStream(fileOut)) {
objOut.writeObject(map);
Expand All @@ -63,14 +65,16 @@ public static void writeV1(RainbowFish rainbowFish, String filename) throws IOEx
* Write V2 RainbowFish to file
*/
public static void writeV2(RainbowFishV2 rainbowFish, String filename) throws IOException {
var map = new HashMap<String, String>();
map.put("name", rainbowFish.getName());
map.put("age", String.format("%d", rainbowFish.getAge()));
map.put("lengthMeters", String.format("%d", rainbowFish.getLengthMeters()));
map.put("weightTons", String.format("%d", rainbowFish.getWeightTons()));
map.put("angry", Boolean.toString(rainbowFish.getAngry()));
map.put("hungry", Boolean.toString(rainbowFish.getHungry()));
map.put("sleeping", Boolean.toString(rainbowFish.getSleeping()));
var map = Map.of(
"name", rainbowFish.getName(),
"age", String.format("%d", rainbowFish.getAge()),
"lengthMeters", String.format("%d", rainbowFish.getLengthMeters()),
"weightTons", String.format("%d", rainbowFish.getWeightTons()),
"angry", Boolean.toString(rainbowFish.getAngry()),
"hungry", Boolean.toString(rainbowFish.getHungry()),
"sleeping", Boolean.toString(rainbowFish.getSleeping())
);

try (var fileOut = new FileOutputStream(filename);
var objOut = new ObjectOutputStream(fileOut)) {
objOut.writeObject(map);
Expand Down

0 comments on commit c836d93

Please sign in to comment.