diff --git a/src/main/java/com/casper/sdk/model/clvalue/CLValueMap.java b/src/main/java/com/casper/sdk/model/clvalue/CLValueMap.java index 009d9d4f9..e5d81c638 100644 --- a/src/main/java/com/casper/sdk/model/clvalue/CLValueMap.java +++ b/src/main/java/com/casper/sdk/model/clvalue/CLValueMap.java @@ -122,9 +122,14 @@ protected void setChildTypes(final Map, ? extend } } - // This needed to be customized to ensure equality is being checked correctly. -// The java Map equals method tries to get the "other" map entry's value by using "this" key object, -// which then fails to find the object since they are "different" and returns always null. + /** + * This needed to be customized to ensure equality is being checked correctly. + * The java Map equals method tries to get the "other" map entry's value by using "this" key object, + * which then fails to find the object since they are "different" and returns always null. + * + * @param o the object to compare + * @return true if the objects are equal, false otherwise + */ @Override public boolean equals(final Object o) { if (o == this) return true; @@ -175,6 +180,15 @@ public int hashCode() { @Override public String toString() { - return getValue() != null ? getValue().entrySet().stream().map(entry -> entry.getKey().toString() + "=" + entry.getValue().toString()).collect(Collectors.joining(", ")) : null; + if (getValue() == null) { + return null; + } else { + return getValue() + .entrySet() + .stream() + .map(entry -> + entry.getKey().toString() + "=" + entry.getValue().toString()).collect(Collectors.joining(", ") + ); + } } } diff --git a/src/main/java/com/casper/sdk/model/clvalue/cltype/CLTypeList.java b/src/main/java/com/casper/sdk/model/clvalue/cltype/CLTypeList.java index a87222e5b..dbbea1761 100644 --- a/src/main/java/com/casper/sdk/model/clvalue/cltype/CLTypeList.java +++ b/src/main/java/com/casper/sdk/model/clvalue/cltype/CLTypeList.java @@ -76,15 +76,8 @@ public void serializeChildTypes(final SerializerBuffer ser) throws NoSuchTypeExc } @Override - public void deserializeChildTypes(final DeserializerBuffer deser) throws ValueDeserializationException, NoSuchTypeException, DynamicInstanceException { - final int childTypeTag = deser.readU8(); - final CLTypeData childType = CLTypeData.getTypeBySerializationTag((byte) childTypeTag); - final AbstractCLType clChildType = CLTypeData.createCLTypeFromCLTypeName(childType.getClTypeName()); - - if (clChildType instanceof AbstractCLTypeWithChildren) { - ((AbstractCLTypeWithChildren) clChildType).deserializeChildTypes(deser); - } - - setListType(clChildType); + public void deserializeChildTypes(final DeserializerBuffer deser) + throws ValueDeserializationException, NoSuchTypeException, DynamicInstanceException { + setListType(deserializeChildType(deser)); } } diff --git a/src/main/java/com/casper/sdk/model/clvalue/cltype/CLTypeTuple2.java b/src/main/java/com/casper/sdk/model/clvalue/cltype/CLTypeTuple2.java index 093d2ff8f..bcf76fa06 100644 --- a/src/main/java/com/casper/sdk/model/clvalue/cltype/CLTypeTuple2.java +++ b/src/main/java/com/casper/sdk/model/clvalue/cltype/CLTypeTuple2.java @@ -41,7 +41,7 @@ protected List getChildTypeObjects() { } @Override - public void serializeChildTypes(SerializerBuffer ser) throws NoSuchTypeException { + public void serializeChildTypes(final SerializerBuffer ser) throws NoSuchTypeException { if (getChildTypes().size() >= 2) { getChildTypes().get(0).serialize(ser); @@ -55,6 +55,4 @@ public void deserializeChildTypes(final DeserializerBuffer deser) getChildTypes().add(deserializeChildType(deser)); getChildTypes().add(deserializeChildType(deser)); } - - }