[FlexBuffers][Java] Add override Key::toString (#5533)
This commit is contained in:
parent
0798b7b698
commit
3f8ce99c50
|
@ -740,6 +740,11 @@ public class FlexBuffers {
|
|||
*/
|
||||
@Override
|
||||
public StringBuilder toString(StringBuilder sb) {
|
||||
return sb.append(toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
int size;
|
||||
for (int i = end; ; i++) {
|
||||
if (bb.get(i) == 0) {
|
||||
|
@ -747,8 +752,7 @@ public class FlexBuffers {
|
|||
break;
|
||||
}
|
||||
}
|
||||
sb.append(Utf8.getDefault().decodeUtf8(bb, end, size));
|
||||
return sb;
|
||||
return Utf8.getDefault().decodeUtf8(bb, end, size);
|
||||
}
|
||||
|
||||
int compareTo(byte[] other) {
|
||||
|
|
|
@ -683,6 +683,7 @@ class JavaTest {
|
|||
// mymap vector
|
||||
FlexBuffers.Map mymap = m.get("mymap").asMap();
|
||||
TestEq(mymap.keys().get(0), m.keys().get(0)); // These should be equal by pointer equality, since key and value are shared.
|
||||
TestEq(mymap.keys().get(0).toString(), "bar");
|
||||
TestEq(mymap.values().get(0).asString(), vec.get(1).asString());
|
||||
TestEq(mymap.get("int").asInt(), -120);
|
||||
TestEq((float)mymap.get("float").asFloat(), -123.0f);
|
||||
|
|
Loading…
Reference in New Issue