Skip to content

Commit

Permalink
Use toString in StringValues
Browse files Browse the repository at this point in the history
  • Loading branch information
ArtDu committed Jun 26, 2024
1 parent cfa0ca1 commit 4164193
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,8 @@ public Map<String, TarantoolFieldMetadata> fromValue(ArrayValue format) {
spaceFormatMetadata.put(
fieldMap.get(FORMAT_FIELD_NAME).toString(),
new TarantoolFieldMetadataImpl(
fieldMap.get(FORMAT_FIELD_NAME).asStringValue().asString(),
fieldMap.get(FORMAT_FIELD_TYPE).asStringValue().asString(),
fieldMap.get(FORMAT_FIELD_NAME).asStringValue().toString(),
fieldMap.get(FORMAT_FIELD_TYPE).asStringValue().toString(),
fieldPosition,
isNullable.isPresent() && isNullable.get().asBooleanValue().getBoolean()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public TarantoolMetadataContainer fromValue(Value value) {

TarantoolSpaceMetadataImpl spaceMetadata = new TarantoolSpaceMetadataImpl();
spaceMetadata.setOwnerId(ID_UNKNOWN);
spaceMetadata.setSpaceName(nameValue.asStringValue().asString());
spaceMetadata.setSpaceName(nameValue.asStringValue().toString());

Value formatValue = space.get(SPACE_FORMAT_KEY);
if (formatValue == null) {
Expand Down Expand Up @@ -140,14 +140,14 @@ private Map<String, TarantoolIndexMetadata> parseIndexes(
throw new TarantoolClientException(
"Unsupported index metadata format: key '" + INDEX_NAME_KEY + "' must have string value");
}
String indexName = indexNameValue.asStringValue().asString();
String indexName = indexNameValue.asStringValue().toString();

Value indexTypeValue = indexMap.get(INDEX_TYPE_KEY);
if (indexTypeValue == null || !indexTypeValue.isStringValue()) {
throw new TarantoolClientException(
"Unsupported index metadata format: key '" + INDEX_TYPE_KEY + "' must have string value");
}
String indexType = indexTypeValue.asStringValue().asString();
String indexType = indexTypeValue.asStringValue().toString();

Value indexUniqueValue = indexMap.get(INDEX_UNIQUE_KEY);
if (indexUniqueValue == null || !indexUniqueValue.isBooleanValue()) {
Expand Down Expand Up @@ -196,7 +196,7 @@ private Map<String, TarantoolIndexMetadata> parseIndexes(
int fieldNumber;
Object fieldPath;
if (fieldPathValue.isStringValue()) {
fieldPath = fieldPathValue.asStringValue().asString();
fieldPath = fieldPathValue.asStringValue().toString();
fieldNumber = getFieldNumberFromFieldPath(fields, (String) fieldPath);
} else {
fieldNumber = fieldPathValue.asIntegerValue().asInt();
Expand All @@ -208,7 +208,7 @@ private Map<String, TarantoolIndexMetadata> parseIndexes(
throw new TarantoolClientException("Unsupported index metadata format: key '" +
INDEX_PARTS_TYPE_KEY + "' must have string value");
}
String fieldType = fieldTypeValue.asStringValue().asString();
String fieldType = fieldTypeValue.asStringValue().toString();

return new TarantoolIndexPartMetadataImpl<>(fieldNumber, fieldType, fieldPath);
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,13 @@ public TarantoolIndexMetadata fromValue(ArrayValue value) {
indexParts = indexPartsValue.list().stream()
.map(partValue -> new TarantoolIndexPartMetadataImpl<>(
partValue.asArrayValue().get(0).asIntegerValue().asInt(),
partValue.asArrayValue().get(1).asStringValue().asString()
partValue.asArrayValue().get(1).asStringValue().toString()
)).collect(Collectors.toList());
} else {
indexParts = indexPartsValue.list().stream()
.map(partValue -> new TarantoolIndexPartMetadataImpl<>(
partValue.asMapValue().map().get(INDEX_FIELD_KEY).asIntegerValue().asInt(),
partValue.asMapValue().map().get(INDEX_TYPE_KEY).asStringValue().asString()
partValue.asMapValue().map().get(INDEX_TYPE_KEY).asStringValue().toString()
)).collect(Collectors.toList());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@ public class DefaultStringValueToCharacterConverter implements ValueConverter<St

@Override
public Character fromValue(StringValue value) {
String stringFromStringValue = value.asString();
String stringFromStringValue = value.toString();
return stringFromStringValue.charAt(0);
}

@Override
public boolean canConvertValue(StringValue value) {
String stringFromStringValue = value.asString();
String stringFromStringValue = value.toString();
return stringFromStringValue.length() == 1;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public class DefaultStringValueToStringConverter implements ValueConverter<Strin

@Override
public String fromValue(StringValue value) {
return value.asString();
return value.toString();
}
}
2 changes: 1 addition & 1 deletion src/main/java/io/tarantool/driver/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
* // the default parameters are set to unlimited, though
* new TarantoolSelectOptions(),
* // convert raw MessagePack array to object by hand
* (v) -> new CustomTuple(v.get(0).asIntegerValue().asInt(), v.get(1).asStringValue().asString()))
* (v) -> new CustomTuple(v.get(0).asIntegerValue().asInt(), v.get(1).asStringValue().toString()))
* .get();
*
* customTuples.forEach(
Expand Down

0 comments on commit 4164193

Please sign in to comment.